学习SpringBoot零碎记录——配置应用URL名称

学习SpringBoot配置应用名称,结果发现坑

到网上找 到

https://blog.csdn.net/qq_40087415/article/details/82497668

server:
port:8088
context-path:/springboot-demo

实际,在我的SpringBoot 的 2.2.2.RELEASE 中,是编译不通过的;

而我后来实践发现:

YAML中配置应用名称

server:
port: 8082
servlet:
context-path: /study

编译通过,日志如下

2020-01-02 22:23:28.851  INFO 5532 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2020-01-02 22:23:28.851 INFO 5532 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.29]
2020-01-02 22:23:28.991 INFO 5532 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/study] : Initializing Spring embedded WebApplicationContext
2020-01-02 22:23:28.991 INFO 5532 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1596 ms
2020-01-02 22:23:29.334 INFO 5532 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2020-01-02 22:23:29.662 INFO 5532 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8082 (http) with context path '/study'
2020-01-02 22:23:29.678 INFO 5532 --- [ main] com.gaole.study.StudyApplication : Started StudyApplication in 3.554 seconds (JVM running for 5.242)

所以估计是SpringBoot版本导致的不一样

上一篇:SpringBoot学习------SpringBoot使用Thymleaf模块访问不了静态页面


下一篇:最新学习springboot 配置注解