[英]Restrict spring resources based on active profiles
根据春季活动概要文件,我限制了bean的创建。 因此,这些不能在生产环境中访问 。
<beans profile="test">
<bean id="testSwaggerConfig" class="com.example.rest.config.SwaggerConfig" />
</beans>
同样,如何基于spring活动配置文件来限制资源 。 这样,在访问html页面时,我应该得到404 。
<mvc:resources mapping="/rest/*.html" location="/rest-doc/" />
我正在从环境变量-Dspring.profiles.active
传递活动配置文件(此信息可能对某人有用)
您可以像这样为每个配置文件定义参数bean
<bean name="profileParam" class="java.lang.String">
<constructor-arg value="/rest/*.html" />
</bean>
并在参数中放置所需的映射,然后像这样使用配置文件中的参数
<mvc:resources mapping="#{profileParam}" location="/rest-doc/" />
因此,对于不同的配置文件,您可以访问不同的映射
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.