在我的应用程序中,我使用@Profile("prod")和注释bean @Profile("demo").第一个,正如你可以猜到:),用于连接到生产数据库的bean,第二个用于注释使用一些假数据库(HashMap或其他)的bean - 以加快开发速度.
我想要的是默认配置文件("prod"),如果它没有被" something-else " 覆盖,它将被使用.
完美将是我的web.xml:
<context-param>
<param-name>spring.profiles.active</param-name>
<param-value>prod</param-value>
</context-param>
Run Code Online (Sandbox Code Playgroud)
然后覆盖它,-Dspring.profiles.active="demo"以便我可以这样做:
mvn jetty:run -Dspring.profiles.active="demo".
Run Code Online (Sandbox Code Playgroud)
但遗憾的是,这不起作用.任何想法我怎么能得到那个?-Dspring.profiles.active="prod"不能在我的所有环境中进行设置.