[英]how to change springboot application start directory?
我在 CENTOS7 上運行一個 springboot 應用程序作為服務。 默認啟動目錄是“/”,現在我想更改為配置文件所在的“/home/centos/fpcyproxy”。
如何改變它?
日志文件:
2018-08-28 14:38:21.645 INFO 2075 --- [main] ljis.ykk.fpcyproxy.Application : Starting Application v1.0.0 on ip-172-31-26-206.cn-northwest-1.compute.internal with PID 2075 (/home/centos/fpcyproxy/fpcyproxy-1.0.0.jar started by root in /)
2018-08-28 14:38:21.662 INFO 2075 --- [main] ljis.ykk.fpcyproxy.Application : No active profile set, falling back to default profiles: default
2018-08-28 14:38:21.828 INFO 2075 --- [main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@19e1023e: startup date [Tue Aug 28 14:38:21 CST 2018]; root of context hierarchy
2018-08-28 14:38:24.673 INFO 2075 --- [main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8443 (https)
2018-08-28 14:38:24.739 INFO 2075 --- [main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2018-08-28 14:38:24.739 INFO 2075 --- [main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.31
2018-08-28 14:38:24.773 INFO 2075 --- [localhost-startStop-1] o.a.catalina.core.AprLifecycleListener : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib]
2018-08-28 14:38:24.928 INFO 2075 --- [localhost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2018-08-28 14:38:24.928 INFO 2075 --- [localhost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 3100 ms
2018-08-28 14:38:25.186 INFO 2075 --- [localhost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Servlet dispatcherServlet mapped to [/]
2018-08-28 14:38:25.189 INFO 2075 --- [localhost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-08-28 14:38:25.190 INFO 2075 --- [localhost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-08-28 14:38:25.190 INFO 2075 --- [localhost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-08-28 14:38:25.190 INFO 2075 --- [localhost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2018-08-28 14:38:25.493 INFO 2075 --- [main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-08-28 14:38:25.918 INFO 2075 --- [main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@19e1023e: startup date [Tue Aug 28 14:38:21 CST 2018]; root of context hierarchy
2018-08-28 14:38:26.114 INFO 2075 --- [main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/fpcy],methods=[POST]}" onto public ljis.ykk.fpcyproxy.domain.FpcyResult ljis.ykk.fpcyproxy.MainController.fpcy(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String)
2018-08-28 14:38:26.135 INFO 2075 --- [main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2018-08-28 14:38:26.136 INFO 2075 --- [main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2018-08-28 14:38:26.176 INFO 2075 --- [main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-08-28 14:38:26.176 INFO 2075 --- [main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-08-28 14:38:26.487 INFO 2075 --- [main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2018-08-28 14:38:26.879 INFO 2075 --- [main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8443 (https) with context path ''
2018-08-28 14:38:26.886 INFO 2075 --- [main] ljis.ykk.fpcyproxy.Application : Started Application in 6.306 seconds (JVM running for 7.104)
服務配置文件內容:
[Unit]
Description=fpcy proxy
After=multi-user.target
[Service]
Type=simple
ExecStart=/usr/bin/java -jar /home/centos/fpcyproxy/fpcyproxy-1.0.0.jar
[Install]
WantedBy=multi-user.target
操作系統版本:
CentOS Linux release 7.5.1804 (Core)
Linux version 3.10.0-862.3.2.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC) ) #1 SMP Mon May 21 23:36:36 UTC 2018
爪哇版:
openjdk version "1.8.0_181"
OpenJDK Runtime Environment (build 1.8.0_181-b13)
OpenJDK 64-Bit Server VM (build 25.181-b13, mixed mode)
如果您正在談論應用程序的 homedir - 嘗試設置 WorkingDirectory 屬性:
[Service]
WorkingDirectory=/home/centos/fpcyproxy
但是,如果您正在談論加載位於外部目錄中的application.properties
,請嘗試設置下一個屬性
ExactStart=/usr/bin/java -jar /home/centos/fpcyproxy/fpcyproxy-1.0.0.jar --spring.config.location=/home/centos/fpcyproxy/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.