[英]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.