一、打包
1.1 选中要部署的项目 右击—>Run As —>Maven clean,结果如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
[INFO] Scanning for projects... [INFO] [INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1 [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building demo 1.0.1 [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-clean-plugin:2.6.1:clean (default-clean) @ demo --- [INFO] Deleting F:\lee\springboot_demo\demo\target [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.781 s [INFO] Finished at: 2018-08-15T16:16:57+08:00 [INFO] Final Memory: 6M/155M [INFO] ------------------------------------------------------------------------ |
1.2 选中要部署的项目 右击 —> Run As —> Maven install,结果如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
Results : Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 [INFO] [INFO] --- maven-jar-plugin:2.6:jar (default-jar) @ demo --- [INFO] Building jar: F:\lee\springboot_demo\demo\target\demo-1.0.1.jar [INFO] [INFO] --- spring-boot-maven-plugin:1.5.14.BUILD-SNAPSHOT:repackage (default) @ demo --- [INFO] [INFO] --- maven-install-plugin:2.5.2:install (default-install) @ demo --- [INFO] Installing F:\lee\springboot_demo\demo\target\demo-1.0.1.jar to D:\devtools\newRepository\com\example\demo\1.0.1\demo-1.0.1.jar [INFO] Installing F:\lee\springboot_demo\demo\pom.xml to D:\devtools\newRepository\com\example\demo\1.0.1\demo-1.0.1.pom [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 18.605 s [INFO] Finished at: 2018-08-15T16:25:41+08:00 [INFO] Final Memory: 38M/292M [INFO] ------------------------------------------------------------------------ |
二、上传jar包到服务器
2.1 可以用命令上传,也可以用FileZilla上传。
#命令方式:
1 |
[root@localhost demo]# rz |
如果没有该命令要么就装一个。
三、启动jar包
3.1 首先查看该端口下的进程,我的项目端口是:8888
1 2 |
[root@localhost demo]# netstat -lanp|grep 8888 tcp 0 0 :::8888 :::* LISTEN 4601/java |
3.2 杀掉该进程
1 |
[root@localhost demo]# kill -9 4601 |
3.3 启动jar包
1 |
[root@localhost demo]# nohup java -jar demo-1.0.1.jar >springboot.log 2>&1 & |
3.4 查看日志
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
[root@localhost demo]# tail -f springboot.log /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v1.5.14.BUILD-SNAPSHOT) 2018-08-15 02:09:12.456 INFO 4897 --- [ main] com.example.DemoApplication : Starting DemoApplication v1.0.1 on localhost with PID 4897 (/opt/project/demo/demo-1.0.1.jar started by root in /opt/project/demo) 2018-08-15 02:09:12.471 INFO 4897 --- [ main] com.example.DemoApplication : The following profiles are active: demo 2018-08-15 02:09:12.776 INFO 4897 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@77a567e1: startup date [Wed Aug 15 02:09:12 PDT 2018]; root of context hierarchy 2018-08-15 02:09:18.002 INFO 4897 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$5e9d3438] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2018-08-15 02:09:19.630 INFO 4897 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8888 (http) 2018-08-15 02:09:19.750 INFO 4897 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat] 2018-08-15 02:09:19.757 INFO 4897 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.31 2018-08-15 02:09:20.050 INFO 4897 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2018-08-15 02:09:20.051 INFO 4897 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 7286 ms 2018-08-15 02:09:20.788 INFO 4897 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/] 2018-08-15 02:09:20.809 INFO 4897 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'statViewServlet' to [/druid/*] 2018-08-15 02:09:20.819 INFO 4897 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*] 2018-08-15 02:09:20.819 INFO 4897 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*] 2018-08-15 02:09:20.823 INFO 4897 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*] 2018-08-15 02:09:20.826 INFO 4897 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*] 2018-08-15 02:09:20.827 INFO 4897 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'webStatFilter' to urls: [/*] 2018-08-15 02:09:20.971 INFO 4897 --- [ main] c.a.d.s.b.a.DruidDataSourceAutoConfigure : Init DruidDataSource 2018-08-15 02:09:23.316 INFO 4897 --- [ main] com.alibaba.druid.pool.DruidDataSource : {dataSource-1} inited 2018-08-15 02:09:23.819 INFO 4897 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default' 2018-08-15 02:09:23.888 INFO 4897 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [ name: default |
3.5 在浏览器地址栏输入项目地址,访问项目检查是否部署成功