[英]How to deploy Springboot app in Linux along with Maven dependencies
我创建了一个 Spring Boot java 应用程序(REST 服务),它在使用 Eclipse 作为 IDE 的 Windows 机器上内部使用 Tomcat 作为 Web 服务器。 它使用 JDK 1.8 和 Maven 作为构建系统。 在这里,我创建了 jar 文件(作为 Maven Install 运行),然后在我的 Windows 机器上从命令提示符调用该 jar 文件。 我在我的 Windows 机器上使用 POSTMAN 测试这些 REST 服务。
现在我必须让它在没有 UI 的 Linux 机器上工作。 您能否帮助我如何在 Linux 机器上实现相同的目标以及如何在 Linux 机器上获得这些依赖项。
首先,确保您的 Linux 服务器安装了 Java。 最匹配您本地的 Java 版本。
其次,利用 maven 插件生成一个可以启动这个项目的 shell 脚本。
下面是一个例子
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>appassembler-maven-plugin</artifactId>
<version>1.10</version>
<!-- bind to package phase -->
<executions>
<execution>
<id>make-appassembly</id>
<phase>package</phase>
<goals>
<goal>assemble</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- set alternative assemble directory -->
<assembleDirectory>${project.build.directory}/${project.artifactId}-${project.version}
</assembleDirectory>
<environmentSetupFileName>envSetup.sh</environmentSetupFileName>
<includeConfigurationDirectoryInClasspath>true</includeConfigurationDirectoryInClasspath>
<repositoryLayout>flat</repositoryLayout>
<repositoryName>lib</repositoryName>
<platforms>
<!-- <platform>windows</platform> -->
<platform>unix</platform>
</platforms>
<!-- Extra JVM arguments that will be included in the bin scripts -->
<extraJvmArguments>-Dlog4j.configuration=file:$BASEDIR/etc/log4j.properties
-Dapplication.properties=file:$BASEDIR/etc/XXX.properties
-Xms2048m
-Xmx12288m -server -showversion -XX:+UseConcMarkSweepGC
-DXXX.log.dir=XXX
-DXXX.app.id=XXX
</extraJvmArguments>
<programs>
<program>
<mainClass>com.xxx.App</mainClass>
<name>xxx.sh</name>
</program></programs>
</configuration>
</plugin>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.