springboot pom问题及注解

springboot pom不需要指定版本号 springboot会自己管理版本号

 <!-- 支持热部署 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <optional>true</optional>
        </dependency>

注意 : 更改完java代码需要重新编译 ctrl+f9,否则依然没用

@Component 加载到容器中

@ConfigurationProperties(prefix = "person") 加上该注解后,就会注入在application.properties中server开头的属性

@Configuration  加上这个的类代表spring IOC容器

这个相当于bean

@Import 多个配置文件整合在一起中间用逗号隔开

@SpringBootTest 配置文件属性的读取

@RunWith(SpringRunner.class) 当一个类用@RunWith注释或继承一个用@RunWith注释的类时,

              JUnit将调用它所引用的类来运行该类中的测试而不是开发者去在junit内部去构建它。我们在开发过程中使用这个特性。

 @ConfigurationProperties和@value的区别

@propertySource("classPath:...")  指定读取配置文件

@ImportResource 导入spring配置文件 让配置文件里面的内容生效

原文地址:https://www.cnblogs.com/ch94/p/10369907.html