![](/img/trans.png)
[英]Script generated via appassembler-maven-plugin is not able to find main class in Spring Boot application
[英]appassembler-maven-plugin add custom entry to classpath
我正在编写一个Java应用程序,它正在使用服务器上运行的另一个第三方应用程序中的某些库。 目前,我正在使用appassembler-maven-plugin构建我的App。 该插件将我的jar(应用程序和依赖项)复制到lib文件夹中,并在bin目录中生成shellscript。
类路径在此shellscirpt中生成。 此解决方案有效,但我将依赖关系瓶子复制了两次(准时在我的应用程序中以及在第三方应用程序中为其编写应用程序)。 我的第三方应用程序的类路径在$ THIRDPARTYAPP_CLASSPATH之类的系统变量中设置。
我想将pom.xml中的依赖项设置为提供,以便应用程序组装者不要将其添加到lib和classpath中,而是要在shellscript中添加systemvar $ THIRDPARTYAPP_CLASSPATH,以便我的应用程序使用来自已安装第三方的jars -应用。
目前,我正在手动执行此操作(在构建后编辑shellscript),并且它可以正常工作。 appassembler-maven-plugin中是否有任何方法可以将systemvar自动添加到类路径中?
我在文档中找不到任何内容,并且此处关于类似问题的其他问题也未得到很好的回答。
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>appassembler-maven-plugin</artifactId>
<version>1.8.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>assemble</goal>
</goals>
</execution>
</executions>
<configuration>
<assembleDirectory>${project.build.directory}/appassembler</assembleDirectory>
<extraJvmArguments>-Xms512m -Xmx1024m</extraJvmArguments>
<generateRepository>true</generateRepository>
<repositoryName>lib</repositoryName>
<repositoryLayout>flat</repositoryLayout>
<includeConfigurationDirectoryInClasspath>true</includeConfigurationDirectoryInClasspath>
<platforms>
<platform>unix</platform>
</platforms>
<programs>
<program>
<mainClass>${mainClass}</mainClass>
<id>app</id>
</program>
</programs>
</configuration>
</plugin>
您可以配置为创建一个<environmentSetupFileName>setup-env</environmentSetupFileName>
,它可以通过CLASSPATH_PREFIX
定义新的类路径部分,这应该可以解决您的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.