Jan*_*yka 9 java spring spring-mvc spring-boot
我有弹簧启动应用程序(1.1.5.RELEASE)并通过配置属性启用我的配置文件spring.profiles.active=MyProfile
配置文件被正确激活,我可以从正在创建的配置文件中看到bean.
然后我@Controller
用了如下:
@Controller
@RequestMapping("/someUrl")
@Profile("MyProfile")
public class MyController {
...
}
Run Code Online (Sandbox Code Playgroud)
未实例化此控制器,并且未映射控制器中使用的URL.在同一个包中,我有另一个不受限制的控制器,@Profile
这些控制器按预期进行实例化和映射.
那么@Profile
在控制器上使用与弹簧启动不兼容的东西吗?我应该使用其他方法吗?
编辑:这似乎是一个错误,好像我-Dspring.profiles.active=MyProfile
作为JVM属性包含控制器实例化:'(
编辑2:所以这里有趣的部分:
如果定义spring.profiles.active
在application.properties
其默认情况下,从classpath中加载thne它的工作原理
当您重命名文件test.properties
并通过@PropertySource("classpath:test.properties")
它包含它停止工作.会针对它提出一个错误.
编辑3:按照承诺:https://github.com/spring-projects/spring-boot/issues/1417
谢谢!
归档时间: |
|
查看次数: |
13781 次 |
最近记录: |