Java 我可以指出位置=“http:path/to/s3/bucket”吗?
我正在从事一个SpringMVC项目,现在我需要将我的资源转移到s3存储桶,但我需要一种机制来方便地在本地和s3之间切换。 我的dispatcher-servlet.xml中有以下代码片段 例如。 对于同一项目上的文件Java 我可以指出位置=“http:path/to/s3/bucket”吗?,java,spring,spring-mvc,amazon-s3,resources,Java,Spring,Spring Mvc,Amazon S3,Resources,我正在从事一个SpringMVC项目,现在我需要将我的资源转移到s3存储桶,但我需要一种机制来方便地在本地和s3之间切换。 我的dispatcher-servlet.xml中有以下代码片段 例如。 对于同一项目上的文件 <mvc:resources location="/app-res/" mapping="/app-res/**"/> 对于本地驱动器上的文件,我可以 <mvc:resources location="file:D:/app-res/" mapping="/a
<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/**"/>
我也尝试过这样做,但无法使用Spring Profiles获得解决方案这是一种可能的解决方案: 参数化外部URL:
<mvc:resources location="${path.to.s3.bucket}" mapping="/app-res/**"/>
创建一些配置文件定义:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:jee="http://www.springframework.org/schema/jee"
xsi:schemaLocation="...">
<beans profile="dev">
<bean id="applicationPropertiesPlaceholder"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:profiles/dev.profile.properties</value>
</list>
</property>
</bean>
</beans>
<beans profile="production">
<bean id="applicationPropertiesPlaceholder"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:profiles/production.profile.properties</value>
</list>
</property>
</bean>
</beans>
</beans>
创建属性文件,然后只需将-Dspring.profiles.active=xyz附加到服务器的JVM参数中