SpringBoot-- Basic Configuration

@

Tomcat configuration

In Springboot project can be built tomcat, netty and other containers. After adding a spring-boot-stater-web-dependent, as a default tomcat web container. If you need further configure tomcat, it can be configured in application.properties.

server.port=8080 //web容器端口号
server.error.path=/error //当前项目出错的时候跳转页面
server.servlet.session.timeout=30m //配置了session的实效时间,m为分钟单位,默认单位为s
server.servlet.context-path=/index //项目名称,默认为/
server.tomcat.uri-encoding=utf-8  // tomcat请求编码
server.tomcat.max-threads=500 // tomcat最大线程数
server.tomcat.basedir=/home/sang/tmp //tomcat运行日志和临时文件的存放目录

profile

When the project development, generally require frequent switching development, test and production environments. springboot stipulated no configuration file name rules environment for application- {profile} .properties, profile placeholder represents the name of the current environment.

E.g:

application-dev.properties

server.port=8080

apllication-test.properties

server.port=8081

application-pro.properties

server.port=8082

Configuration environment using the appropriate method in more Setting:

In the configuration application.properties

spring.profile.active=dev

We can also be configured in the code.

Only you need to start the main method of adding class:

SpringApplicationBuilder buider = new SpringApplicationBuilder(当前类.class);
builder.application().setAdditionalProfiles("dev");
builder.run(args);

Guess you like

Origin www.cnblogs.com/luckyhui28/p/12343740.html