springboot專案打包部署到Linux伺服器步驟
阿新 • • 發佈:2019-02-20
一、打包
1.1 選中要部署的專案 右擊—>Run As —>Maven clean,結果如下:
[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,結果如下:
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上傳。
#命令方式:
[root@localhost demo]# rz
如果沒有該命令要麼就裝一個,具體步驟,之後會發表《Linux安裝rz和sz》
三、啟動jar包
3.1 首先檢視該埠下的程序,我的專案埠是:8888
[root@localhost demo]# netstat -lanp|grep 8888
tcp 0 0 :::8888 :::* LISTEN 4601/java
3.2 殺掉該程序
[root@localhost demo]# kill -9 4601
3.3 啟動jar包
[root@localhost demo]# nohup java -jar demo-1.0.1.jar >springboot.log 2>&1 &
3.4 檢視日誌
[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