在netbeans中为maven项目设置自定义运行时类路径 [英] Setting custom runtime classpath for a maven project in netbeans
问题描述
我想在netbeans中运行我的maven项目时添加自定义类路径。到目前为止,我已尝试在项目属性中的运行项目操作中添加以下内容:
I want to add a custom classpath when I'm running my maven project from within netbeans. So far I've tried adding the following to the Run Project action in the project properties:
exec.args=-classpath %classpath;c:/QUASR/duplicateRemoval.jar;c:/QUASR/lib/QUASR.jar ${packageClassName}
exec.args=-cp %classpath;c:/QUASR/duplicateRemoval.jar;c:/QUASR/lib/QUASR.jar ${packageClassName}
exec.args=-cp c:/QUASR/duplicateRemoval.jar;c:/QUASR/lib/QUASR.jar ${packageClassName}
但没有运气,没有设置自定义运行时类路径。
but no luck, the custom runtime classpath is not set.
推荐答案
您应该在 run-with-netbeans
你的pom声明了附加的依赖关系(使用提供的
作用域在发行版中不包括它们。)
You should add a new profile run-with-netbeans
in your pom that declares the additional dependencies (use the provided
scope to not include them in the release).
您必须将新的配置文件添加到IDE以在命令行中使用 -P run-with-netbeans
选项运行pom。
Then you'll have to add the new profile to your IDE to run the pom with the -P run-with-netbeans
option in the command line.
<properties>
<!-- provided by default -->
<my-dynamic-scope>provided</my-dynamic-scope>
</properties>
<profiles>
<profile>
<id>run-with-netbeans</id>
<properties>
<!-- compile when running in IDE -->
<my-dynamic-scope>compile</my-dynamic-scope>
</properties>
<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
</dependency>
</dependencies>
</profile>
</profiles>
<dependencies>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>${commons-lang.version}</version>
<scope>${my-dynamic-scope}</scope>
</dependency>
</dependencies>
上面的代码段只有在使用 run-with-netbeans
个人资料。它还设置了一个属性 my-dynamic-scope
,可以在您的依赖块中使用来更改范围。
The snippet above add log4j only when running with the run-with-netbeans
profile. It also sets a property my-dynamic-scope
that can be used in your dependency block to change the scope.
HIH
M。
HIH M.
这篇关于在netbeans中为maven项目设置自定义运行时类路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!