可以在NetBeans中创建类似于Eclipse的“运行配置”的东西吗?我正在做一个巨大的项目,该项目目前在Eclipse中没有划分为任何子项目。事实上,项目中有许多应用程序都有自己的main-method和单独的类路径。我知道,一团糟。
我正在考虑将这个项目迁移到NetBeans。从长远来看,创建许多项目是明智的,但现在,如果我可以在NetBeans中做与在Eclipse中类似的事情,那么它将是一个真正的救命稻草:创建具有自己类路径的“启动器”。这个是可能的吗?
如果很容易用“外部”项目来模仿这种行为,那么也欢迎关于这方面的提示。
发布于 2010-03-22 03:35:18
几个月后,我不知道这是否有什么意义:http://wiki.netbeans.org/FaqTwoMainClassesWithArguments
发布于 2017-02-04 01:25:24
在Maven中使用Profiles与Eclipse提供的Run Configuirations很接近,但不是很灵活。这样你就可以在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>然后在Project Properties中单击Run。您的配置文件将列在Configuration:的下拉菜单中。在这里,您可以为POM中列出的每个配置文件创建参数。

这并不是这个问题的完整答案。显然,NetBeans缺乏在集成开发环境中快速、轻松地在运行配置之间切换的能力,并且这些配置独立于构建工具并且位于存储库之外。我连接到不同的数据库,并根据我正在处理的项目的不同方面使用不同的输入配置。这在NetBeans中是非常有限的。我不希望我所有的运行配置都签入到存储库中,这就是将配置文件添加到项目POM中时会发生的事情。
编辑:所以我就快找到上面的答案了。单击Customize...按钮,您现在可以选择
对此
实例保持私有

现在,此配置文件/配置将不会存储在POM中。实际上,它存储在Project Files - nb-configuration.xml中。

发布于 2009-08-13 10:32:20
我要做的就是使用Ant,并让一堆目标调用您所在的main()方法。
事实上,这样做的好处是,您甚至可以在IDE外部的命令行上使用这些“快捷键”,这对于持续集成构建和诸如此类的事情很有用。
请注意,NetBeans甚至允许您为您选择的Ant目标定义工具栏/菜单快捷方式,我发现这非常有用。
例如,我的项目构建文件通常都有启动和停止Tomcat的快捷方式,请参见下面的示例:
http://ptrthomas.wordpress.com/2006/03/25/how-to-start-and-stop-tomcat-from-ant/
https://stackoverflow.com/questions/1268211
复制相似问题