java<mvc:resources>我可以指向location=“http:path/to/s3/bucket”吗?
我正在从事一个Spring MVC项目,现在我需要将我的资源转移到s3 bucket,但我需要一种机制来方便地在本地和s3之间切换。 我的dispatcher servlet中有以下代码片段。xml
例如。 对于同一项目中的文件
<mvc:resources location="/app-res/" mapping="/app-res/**"/>
对于本地驱动器上的文件,我可以
<mvc:resources location="file:D:/app-res/" mapping="/app-res/**"/>
我也可以这样做吗
<mvc:resources location="http:path/to/s3/bucket" mapping="/app-res/**"/>
我也试过这么做,但没能找到解决办法
# 1 楼答案
使用弹簧配置文件是一种可能的解决方案:
http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#beans-definition-profiles-xml
参数化外部URL:
创建一些配置文件定义:
创建属性文件,然后只需将
-Dspring.profiles.active=xyz
附加到服务器的JVM参数