Spring Boot 有两种部署到服务器的方式,这里介绍官方推荐的(jar包)
一、首先进行application.properties配置
# EMBEDDED SERVER CONFIGURATION (ServerProperties) server.port=8085 server.servlet.context-path=/cwx management.server.port=8086 management.server.servlet.context-path=/cwx management.server.address=127.0.0.1 server.tomcat.accept-count=100 server.tomcat.max-connections=10000 server.tomcat.max-threads=200 server.tomcat.min-spare-threads=10 server.tomcat.uri-encoding=UTF-8 # HTTP (HttpProperties) spring.http.encoding.charset=UTF-8 spring.http.encoding.enabled=true # BANNER spring.banner.charset=UTF-8 # LOGGING logging.file=alipaygndemo_service.log logging.path=log # IDENTITY (ContextIdApplicationContextInitializer) spring.application.name=alipaygndemo_service mybatis.type-aliases-package=com.xxxxx.entity mybatis.config-locations=classpath:mybatis/mybatis-config.xml mybatis.mapper-locations=classpath:mybatis/mapper/*.xml spring.datasource.driverClassName=com.mysql.jdbc.Driver spring.datasource.url=jdbc:mysql://192.168.1.1:4007/merchant_receipt?useUnicode=true&characterEncoding=utf-8 spring.datasource.username=root spring.datasource.password=123456
二、marven配置文件
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.macaupass</groupId> <artifactId>alipaygndemo-service</artifactId> <version>0.0.1</version> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.5.RELEASE</version> </parent> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.55</version> </dependency> <!-- <dependency> <groupId>commons-codec</groupId> <artifactId>commons-codec</artifactId> <version>1.12</version> </dependency> --> <!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger2 --> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.9.2</version> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version>2.9.2</version> </dependency> <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>1.2.0</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.30</version> </dependency> <dependency> <groupId>joda-time</groupId> <artifactId>joda-time</artifactId> <version>2.7</version> </dependency> <dependency> <groupId>commons-net</groupId> <artifactId>commons-net</artifactId> <version>3.5</version> </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.9</version> </dependency> <dependency> <groupId>com.jcraft</groupId> <artifactId>jsch</artifactId> <version>0.1.51</version> </dependency> <!-- jsch 所依赖的jar包 --> <dependency> <groupId>com.jcraft</groupId> <artifactId>jzlib</artifactId> <version>1.0.7</version> </dependency> </dependencies> <properties> <java.version>1.8</java.version> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <skipTests>true</skipTests> </properties> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project>
注意:在打包的时候,如果遇到数据库连不通打包失败的情况,需要在pom文件下添加 <skipTests>true</skipTests> 这一行
<properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <java.version>1.8</java.version> <skipTests>true</skipTests> </properties>
三、打成jar包
然后会出现打好的jar包:
四、部署启动服务
进入到这个jar的根目录下,执行以下命令启动服务:
java -jar alipaygndemo-service-0.0.1.jar
五、查看进程:
ps -ef|grep java
原文链接:https://www.cnblogs.com/caoweixiong/p/10718479.html
© 版权声明
声明📢本站内容均来自互联网,归原创作者所有,如有侵权必删除。
本站文章皆由CC-4.0协议发布,如无来源则为原创,转载请注明出处。
THE END