我有一个 Maven 项目,它保存配置信息并将其打包在 zip 文件中。我使用 Maven 依赖插件将内容解压到 ${project.build.directory}/unpacked,然后运行资源插件来过滤内容并将它们直接转储到 ${project.build.directory}。
当我运行 maven exec 时,我的 logback.xml 没有被拾取。看来类路径设置为 ${basedir},但我希望它同时具有 ${project.build.directory}、测试类、测试类和类。
每当我尝试添加类路径元素时,都会收到配置错误。
我应该如何配置我的 pom.xml 来支持这一点,这是否可能?
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>run</id>
<phase>package</phase>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<workingDirectory>${project.build.directory}</workingDirectory>
<mainClass>${jar.mainClass}</mainClass>
</configuration>
</plugin>
最佳答案
这应该可以解决问题。
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<archive>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
<manifest>
<addClasspath>true</addClasspath>
<!-- <classpathPrefix></classpathPrefix> -->
<mainClass>com.stackoverflow.test</mainClass>
</manifest>
<manifestEntries>
<Class-Path>${project.build.outputDirectory}/unpacked/logback.xml</Class-Path>
</manifestEntries>
</archive>
</configuration>
</plugin>
关于java - maven exec 插件 - logback 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7321066/