The same code can be connected to different databases for JUnit testing without changing the configuration file.
The difference between non-development, testing and production environments. Instead, I stand here and hit wherever I point!
To avoid reinventing the wheel, refer to the blog post:
Main keywords:
Maven dependencies:
<dependency>
<groupId>com.github.stefanbirkner</groupId>
<artifactId>system-rules</artifactId>
<version>1.16.1</version>
<scope>test</scope>
</dependency>
Java类:EnvironmentVariables
The following blog post is for reference only and has not been tested.
How to set environment variables or system properties in Spring tests? - SegmentFault Sifou