SpringMVC配置多个properties文件之通配符

在springmvc中配置加载properties文件一般会在xml文件中配置如下:

 <context:property-placeholder location="classpath:resources/properties/zza.properties"
        ignore-unresolvable="true" /> 

如果希望在项目中添加了一个新的模块,并且希望新的模块和之前项目相对独立,需要新添加一个properties文件的话,那么需要在xml配置文件中,再配置一份。比如:

<context:property-placeholder location="classpath:resources/properties/zza.properties"
        ignore-unresolvable="true" /> 

        <context:property-placeholder location="classpath:resources/properties/weixin.properties"
        ignore-unresolvable="true" />

这样做就太麻烦了,每次添加完properties文件还得在xml文件中添加。并且还必须把ignore-unresolvable属性设置为true。解决方案是:利用通配符。具体如下:

    <context:property-placeholder   location="classpath*:resources/properties/*.properties" />

版权声明:本文为博主原创文章,未经博主允许不得转载。

时间: 2024-08-12 13:14:02

SpringMVC配置多个properties文件之通配符的相关文章

SpringMVC+HibernateValidator,配置在properties文件中的错误信息回显前端页面出现中文乱码

问题: 后台在springMVC中使用hibernate-validator做参数校验的时候(validator具体使用方法见GOOGLE),用properties文件配置了校验失败的错误信息.发现回显给前端页面的时候中文错误信息显示乱码. 封装参数的POJO类 public class UserReqBean { @NotNull(message="{user.name.notnull}") private String userName; } ValErrMsg.propertie

spring配置中,properties文件以及xml文件配置问题

spring方便我们的项目快速搭建,功能强大,自然也会是体系复杂! 这里说下配置文件properties管理的问题. 一些不涉及到代码逻辑,仅仅只是配置数据,可以放在xxxx.properties文件里面,项目功能复杂的时候,往往properties文件很多,这时,就比较容易让人困惑,有些properties的文件内容总是加载不起来,应用启动时,就不断爆出错误,说某某参数加载失败,这个是什么原因呢? 其实,这个是spring配置的时候,org.springframework.beans.fact

配置SpringBoot访问jsp文件

添加jsp文件依赖包 <!-- 对jsp的支持的依赖 --> <dependency> <groupId>org.apache.tomcat.embed</groupId> <artifactId>tomcat-embed-jasper</artifactId> <scope>provided</scope> </dependency> <!-- jsp页面使用jstl标签 --> &l

spring 框架的xml文件如何读取properties文件数据

第一步:在spring配置文件中 注意:value可以多配置几个properties文件 <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>/db.

SpringMVC加载配置Properties文件的几种方式

最近开发的项目使用了SpringMVC的框架,用下来感觉SpringMVC的代码实现的非常优雅,功能也非常强大, 网上介绍Controller参数绑定.URL映射的文章都很多了,写这篇博客主要总结一下SpringMVC加载配置Properties文件的几种方式 通过读取Config文件的配置例如: Map<String, String> group = ConfigurationManager.GetConfiguration("config1"); this.setBcp

Spring中配置和读取多个Properties文件

public class PropertiesFactoryBeanextends PropertiesLoaderSupportimplements FactoryBean, InitializingBean Allows for making a properties file from a classpath location available as Properties instance in a bean factory. Can be used to populate any be

log4j.properties文件的配置

Log4j有三个主要的组件:Loggers(记录器),Appenders (输出源)和Layouts(布局).这里可简单理解为日志类别,日志要输出的地方和日志以何种形式输出.综合使用这三个组件可以轻松地记录信息的类型和级别,并可以在运行时控制日志输出的样式和位置. 1.Loggers Loggers组件在此系统中被分为五个级别:DEBUG.INFO.WARN.ERROR和FATAL.这五个级别是有顺序的,DEBUG < INFO < WARN < ERROR < FATAL,分别用

Spring中配置和读取多个Properties文件--转

public class PropertiesFactoryBeanextends PropertiesLoaderSupportimplements FactoryBean, InitializingBean Allows for making a properties file from a classpath location available as Properties instance in a bean factory. Can be used to populate any be

Liferay SDK 6.2与7.0中build.[$username].properties 文件的配置

这篇文章是针对刚开始开发Liferay的新手写的,希望能够帮到刚入门的开发者减少一些配置上的麻烦. 前提: 1. 下载了Liferay IDE(Liferay的官方开发工具) 2.下载了Liferay SDK 6.2或7.0(取决于你用哪一个版本开发,7.0主要采用osgi技术) 3. 下载了Liferay Portal的对应版本(这个链接里面包含了各种可以下载的资源,需要的liferay资源在这里都可以找到) 在创建Liferay Plugin项目时,如果你的工作空间中没有SDK时,会要求你引