1. The first thing I know is
The springboot project can use the following three types of configuration files and can exist at the same time.
The different configuration contents read by springboot will be merged. If there are configurations with the same configuration items, they will take effect in the following priority order:
> >
2. The same type of configuration file
Placed in different locations, the order of effectiveness is as follows:
- Level 1: Directory of the same level: config/[highest)
- Level 2: Directory of the same level:
- Level 3: classpath: config/
- Level 4: classpath:
3. In a configuration file
You can also configure different environment configurations as follows
#Set the enabled environmentspring: profiles: active: dev --- spring: profiles: dev server: port: 81 --- spring: profiles: test server: port: 82 --- spring: profiles: pro server: port: 83
4. You can read the configuration in the pom file in the file
Can be used to configure the current environment
#Set the enabled environmentspring: profiles: active: ${} --- spring: profiles: dev server: port: 81 --- spring: profiles: test server: port: 82 --- spring: profiles: pro server: port: 83
The configuration in the pom file is as follows:
<plugin> <artifactId>maven-resources-plugin</artifactId> <configuration> <encoding>utf-8</encoding> <useDefaultDelimiters>true</useDefaultDelimiters> </configuration> </plugin>
<profiles> <!--devenvironment--> <profile> <id>dev</id> <properties> <>dev</> </properties> </profile> <!--testenvironment--> <profile> <id>test</id> <properties> <>test</> </properties> </profile> <!--proenvironment--> <profile> <id>pro</id> <properties> <>pro</> </properties> <activation> <activeByDefault>true</activeByDefault> </activation> </profile> </profiles>
Summarize
The above is personal experience. I hope you can give you a reference and I hope you can support me more.