Spring 当我的属性文件中有自定义名称时,如何添加特定于配置文件的属性文件
我在项目的src/main/resources文件夹中有名为:transactionexpiry.properties的属性文件 我能够通过@PropertySource(“classpath:/transactionexpiry.properties”)读取代码中的属性 现在我不想添加应用程序范围和特定于环境的配置文件,如transactionexpiry-dev.properties、transactionexpiry local.properties等 但同样适用于application.properties、application-dev.properties、application-local.propertiesSpring 当我的属性文件中有自定义名称时,如何添加特定于配置文件的属性文件,spring,spring-boot,Spring,Spring Boot,我在项目的src/main/resources文件夹中有名为:transactionexpiry.properties的属性文件 我能够通过@PropertySource(“classpath:/transactionexpiry.properties”)读取代码中的属性 现在我不想添加应用程序范围和特定于环境的配置文件,如transactionexpiry-dev.properties、transactionexpiry local.properties等 但同样适用于application.
有没有办法让它与我以前的设置一起工作?如果您使用的是spring配置文件:
-Dspring.profiles.active=dev
然后可以调用属性文件,如:
@PropertySource("classpath:/transactionexpiry${spring.profiles.active}.properties")
如果您使用的是弹簧配置文件:
-Dspring.profiles.active=dev
然后可以调用属性文件,如:
@PropertySource("classpath:/transactionexpiry${spring.profiles.active}.properties")