手机网站总是自动跳转,php制作投票网站,广东东莞招工信息最新招聘,网站的下载二维码怎么做1. Import
Import注解是引入java类#xff1a;
导入Configuration注解的配置类#xff08;4.2版本之前只可以导入配置类#xff0c;4.2版本之后也可以导入普通类#xff09;导入ImportSelector的实现类导入ImportBeanDefinitionRegistrar的实现类
SpringBootApplication…1. Import
Import注解是引入java类
导入Configuration注解的配置类4.2版本之前只可以导入配置类4.2版本之后也可以导入普通类导入ImportSelector的实现类导入ImportBeanDefinitionRegistrar的实现类
SpringBootApplication
Import(MyCustomize.class)
public class StartBootReadConfig {public static void main(String[] args) {SpringApplication.run(StartBootReadConfig.class, args);}AutowiredMyCustomize myCustomize;PostConstructpublic void init(){myCustomize.printf();}
}2. ImportResource ImportResource是引入spring配置文件.xml它导入的是使用xml配置文件注入的对象。
新建测试类
public class MyCustomize {public void printf(){System.out.println(MyCustomize.printf);}
}新建一个bean的配置文件mycustomize.xml
?xml version1.0 encodingUTF-8?
beans xmlnshttp://www.springframework.org/schema/beansxmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsdbean idmycustomize namemycustomize classcom.lx.readconfig.service.MyCustomize/bean
/beans
使用ImportResource导入
SpringBootApplication
ImportResource(mycustomize.xml)
public class StartBootReadConfig {public static void main(String[] args) {SpringApplication.run(StartBootReadConfig.class, args);}AutowiredMyCustomize myCustomize;PostConstructpublic void init(){myCustomize.printf();}} 3.PropertySource
PropertySource是引入自定义配置文件(yml或properties)用于spring boot 配置文件(yml或properties)与实体属性映射。
Component
//PropertySource(classpath:myext.properties)
//PropertySource默认不支持yml或者yaml的解析
PropertySource(value classpath:myext.yml, factory CustomizePropertySourceFactory.class)
ConfigurationProperties(prefix keyfieldpropertiesext)
Data