给定:
<beans ... namespace decelerations>
<bean id="foo" class="com.example.foo" />
<beans profile="abc">
<bean id="bar" class="com.exmaple.bar" />
</beans>
</bean>
foo 注册的配置文件的名称是什么?有没有办法在另一个配置文件定义中覆盖 foo ?当没有明确指定配置文件时,spring 中的默认配置文件是否有名称。
最佳答案
spring 中的默认配置文件是“default”,请参见:https://jira.springsource.org/browse/SPR-8203
您可以通过以下方式更改 web.xml 中的默认配置文件:
<context-param>
<param-name>spring.profiles.default</param-name>
<param-value>production</param-value>
</context-param>
命令行:
-Dspring.profiles.default=production
环境变量:
export spring_profiles_default=production
如果设置了 Activity 配置文件,它将覆盖默认配置。
关于java - 如何指定 bean 将在 Spring 中注册的默认配置文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14442075/