【问题标题】:External property file configuration on Spring MVC applicationSpring MVC 应用程序上的外部属性文件配置
【发布时间】:2016-05-25 13:15:20
【问题描述】:

我创建了 spring mvc 应用程序,并且我在 D:\propertiesfile.properties 上有一个外部属性文件,我需要知道如何在 servlet-context.xml 中配置属性文件

 <beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/views/" />
<beans:property name="suffix" value=".jsp" />
</beans:bean>
<context:property-placeholder location="file:D:\propertiesfile.properties>
<context:component-scan base-package="com.example.properties" />

但它不起作用。请指导我

【问题讨论】:

    标签: java spring spring-mvc


    【解决方案1】:

    如果可能,我建议使用弹簧靴。在spring boot中,您可以在编译的jar文件之外拥有一个application.properties,甚至无需定义它的位置,因为spring boot会自行找到它。它还带有自动配置,因此基本上是“xml”和很多配置开销“死”。如果需要,你可以很容易地进行配置,我建议你看这里:spring boot external configuration

    【讨论】:

      猜你喜欢
      • 2012-01-06
      • 2017-08-18
      • 2019-09-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-20
      • 1970-01-01
      • 2017-11-28
      相关资源
      最近更新 更多