NetBeans和类似Eclipse的“运行配置”
是否有可能在NetBeans中创建类似Eclipse的“运行配置”的东西?我正在研究一个巨大的项目,该项目目前在Eclipse中不分为任何子项目。事实上,项目中有许多应用程序都有自己的主要方法和独立的类路径。我知道,这是一团糟。NetBeans和类似Eclipse的“运行配置”
我在考虑将项目迁移到NetBeans。从长远来看,创建许多项目是明智的,但现在如果我可以在NetBeans中执行类似于Eclipse的项目,它将会是一个真正的生命保护程序:创建具有自己的类路径的“启动器”。这可能吗?
如果使用“外部”项目很容易模拟此行为,那么也可以提供相关提示。
我会做的是使用Ant和有一堆来调用你的intrerested在main()方法的目标。
其实这样做的好处是,你可以使用这些甚至用这些“捷径“在命令行上的IDE之外,对于持续集成构建以及类似的东西非常有用。
请注意,NetBeans允许您定义工具栏/菜单快捷方式到您选择的Ant目标,我觉得这非常有用。
例如我的项目建设文件通常具有快捷方式甚至开始和停止Tomcat,请参阅本为例:
http://ptrthomas.wordpress.com/2006/03/25/how-to-start-and-stop-tomcat-from-ant/
在Maven中使用配置文件接近于Eclipse提供的运行配置,但并不十分灵活。所以,你可以在你的pom.xml定义您的个人资料
<profiles>
<profile>
<id>Config1</id>
<build>
<plugins>
<plugin>
<!-- create an all-in-one executable jar with maven-shade-plugin bound
to phase:package special handling for spring.handlers/spring.schemas files
to prevent overwriting (maven-shade-plugin joins them to one file) usage:
cd to <project>/target java -jar hello-world-java-1.0-executable.jar spring/batch/job/hello-world-job.xml
helloWorldJob -->
<artifactId>maven-shade-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<transformers>
<!-- Added this one because of runtime exception - No container
provider supports the type class org.glassfish.grizzly.http.server.HttpHandler
see - http://stackoverflow.com/questions/9787265/grizzly-and-jersey-standalone-jar -->
<transformer
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.myCompany.nexgen.main.Start</mainClass>
<!-- <mainClass>org.springframework.boot.loader.Launcher</mainClass> -->
</transformer>
<transformer
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.handlers</resource>
</transformer>
<transformer
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.schemas</resource>
</transformer>
</transformers>
<shadedArtifactAttached>true</shadedArtifactAttached>
<!-- configures the suffix name for the executable jar here it will
be '<project.artifact>-<project.version>-executable.jar' -->
<shadedClassifierName>executable</shadedClassifierName>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>myLocalrun</id>
<build>
<directory>
c:\sdev\myDev\myProj
</directory>
</build>
</profile>
</profiles>
然后在项目属性点击运行。配置文件的下拉菜单中将列出您的配置文件。您可以在这里创建POM中列出的每个配置文件的参数。
这不是一个完整的答案的问题。很显然,NetBeans缺乏在IDE内快速轻松地切换运行配置的功能,并且这些配置独立于构建工具,并且独立于存储库外部。我附加到不同的数据库,并根据我正在处理的项目的哪些方面使用不同的输入配置。这在NetBeans中非常有限。我不希望将所有运行配置都检入到存储库中,这些配置文件将添加到项目POM中。
[编辑]:所以我几乎在那里的答案上面。点击自定义...按钮,你就可以选择
保持为私有IDE实例
现在这个配置文件/配置不会被保存在POM。实际上它存储在Project Files-nb-configuration.xml中。
建议的解决方案假定使用Ant的时候大部分项目已经转移到Maven的gradle或。 – 2015-12-21 13:50:17
甚至有一个插件可用,运行参数,但它又是基于蚂蚁。寻找与使用的构建工具无关的功能。 http://plugins.netbeans.org/plugin/53855/run-with-arguments – 2017-02-03 16:45:48