方法1. 使用mvn插件打包(推荐)
pom代码
org.apache.maven.pluginsmaven-surefire-plugin2.22.2trueorg.apache.maven.pluginsmaven-compiler-plugin3.8.11.81.8UTF-8org.springframework.bootspring-boot-maven-plugintruecom.iristar.TestApplicationrepackagerepackage
启动脚本
set path=%PATH%;dlljava -jar ./target/evalserver-1.0-SNAPSHOT.jar spring.config.addition-location=./application.properties #!/bin/bashexport LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./dll java -jar ./target/evalserver-1.0-SNAPSHOT.jar spring.config.addition-location=./application.properties
方法2. 使用 idea的Artifacts打包
方法3. 使用package打包
pom代码
org.springframework.bootspring-boot-maven-plugin-Dfile.encoding=UTF-8com.iristar.center.ht.ApiServerorg.apache.maven.pluginsmaven-surefire-plugintrueorg.apache.maven.pluginsmaven-compiler-plugin1.81.8utf8-XDignore.symbol.filetrueorg.codehaus.mojoappassembler-maven-plugin2.0.0Make Assemblypackageassembleunixwindows${project.build.directory}/productlibbinconftruesrc/main/resourcesflatUTF-8logstmpcom.iristar.center.ht.ApiServerApiServer-server-Xmx2G-Xms2G-Dfile.encoding=UTF-8<!----><!----><!--{project.basedir}/lib--><!--${project.build.directory}/product/lib--><!----><!--**/*--><!----><!----><!---->src/main/java**/*.xml**/*.properties**/*.ymlfalsesrc/main/resources**/*.*false
命令如下
mvn clean package appassembler:assemble
注意事项:
问题(1):
windows下提示输入行太长
解决方法:
将原来的引入包的地方全部删掉,改为*
问题(2):
windows下提示找不到动态库
解决方法:
setx -m PATH “%PATH%;./”
linux下提示找不到动态库
解决方法:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./