1. configuration file application.properties
##The port number
server.port=8888
## environment configuration file used by the project ## dev prod production test development environment test environment
spring.profiles.active=test
## project root path
server.servlet.context-path=/ysd
2. Configuring custom properties
##学生类自定义属性
student.name=Tom
student.age=22
student.birthday=1996/01/10
student.sex=true
student.hobbies[0]=swimming
student.hobbies[1]=basketball
student.skills[0]=programming
student.skills[1]=test
student.address.province=henan
student.address.city=zhengzhou
-------------------------------
@Component based annotation
@ConfigurationProperties (prefix = "student") profiles with the class name for an identical prefix
@PropertySource ({ "classpath: stu.properties" }) Profile Path
3.pom.xml
<!-- 项目设置 : 编码格式 UTF-8 -->
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<! - hot deployment ->
<dependency>
<the groupId> org.springframework.boot </ the groupId>
<the artifactId> Boot-Spring-DevTools </ the artifactId>
<optional> to true </ optional> <! - = optional true, rely not passed, the project relies devtools; dependence myboot project after project if you want to use devtools, need to re-introduce ->
<scope> to true </ scope> <- hot deployment ->!
</ dependency >
<build>
<plugins>
<!-- SpringBoot插件 -->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
<!-- SpringBoot项目打包jar名称 -->
<finalName>demo</finalName>
</build>