在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