测试配置

@RunWith(SpringRunner.class)
@SpringBootTest
@Configuration
@ActiveProfiles("test")
public class ApplicationTests {
    @Test
    public void test() {

    }
}
  • 测试类集成此类就可以实现读取测试的配置文件application-test.properties
  • 在application.properties中配置spring.profiles.active=dev,就可以读取application-dev.properties配置文件信息,在application.properties中可以写一些公共配置,dev中写特殊配置

idea热加载工具devtools工具生效

  1. 首先加pom
<!-- SpringBoot自带热加载开发工具 -->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-devtools</artifactId>
    <scope>runtime</scope>
</dependency>
  1. 在idea选项Compiler中把Build project automatically打钩
  2. 再快捷键shift+command+alt+/ 再选择registry,把compiler.automake.allow.when.app.running勾上

相关文章:

  • 2021-08-14
  • 2021-08-07
  • 2022-12-23
  • 2022-12-23
  • 2021-04-05
  • 2021-04-20
  • 2021-07-08
  • 2021-12-04
猜你喜欢
  • 2022-12-23
  • 2021-12-23
  • 2022-01-02
  • 2021-10-05
  • 2021-07-29
  • 2021-11-28
  • 2021-06-02
相关资源
相似解决方案