在我的应用程序中,我使用 @Profile("prod")和 @Profile("demo")注释 bean。
正如您所猜测的:) ,第一个用于连接到产品 DB 的 bean,第二个用于注释使用假 DB (HashMap或其他)的 bean,以加快开发速度。
我想有的是默认配置文件("prod") ,将使用总是,如果它不是由“ 别的东西”覆盖。
最好是在我的 web.xml:
<context-param>
<param-name>spring.profiles.active</param-name>
<param-value>prod</param-value>
</context-param>
然后用 -Dspring.profiles.active="demo"覆盖它,这样我就可以:
mvn jetty:run -Dspring.profiles.active="demo".
但遗憾的是,这并没有奏效。知道我怎么才能做到吗?在所有环境中设置 -Dspring.profiles.active="prod"不是一个选项。