Spring无配置使用properties文件
利用@PropertySource注解加载
@Configuration
@ComponentScan(basePackages="*")
@PropertySource({"classpath:config.properties"})
//@Import(DataSourceConfig.class)
public class DefaultAppConfig {
@Bean
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
return new PropertySourcesPlaceholderConfigurer();
}
}
利用@Value使用
@Value("${app.name}")
private String appName;
@Value("${app.version}")
private String appVersion;
Spring无配置使用properties文件的更多相关文章
- Java中如何获取spring中配置的properties文件内容
有2种方式: 一. 1.通过spring配置properties文件 [java] <bean id="propertyConfigurer" class=&qu ...
- JdbcTemplae使用入门&&Spring三种连接池配置&&Spring配置文件引用外部properties文件
JdbcTemplate的使用 Spring为了各种支持的持久化技术,都提供了简单操作的模版和回调. JdbcTemplate 简化 JDBC 操作HibernateTemplate 简化 Hiber ...
- spring 配置文件中使用properties文件 配置
配置Bean载入properties文件: <bean id="propertyPlaceholderConfigurer" class="org.springfr ...
- 解密Spring加载的Properties文件
Spring的框架中,org.springframework.beans.factory.config.PropertyPlaceholderConfigurer类可以将.properties(key ...
- 在Spring环境下存取properties文件…
Spring中PropertyPlaceholderConfigurer的使用 (1) 基本的使用方法是 classpath:/spring/include/dbQuery.properties 其中 ...
- Spring MVC 中使用properties文件
首先要搭建Spring mvc的环境,然后开始properties文件里的配置: 第一步:在springcontext中注入properties,具体路径自己调整 <bean id=" ...
- Spring 通过配置文件注入 properties文件
当我们需要将某些值放入 properties文件 key=value 的方式,获取文件信息使用spring 注入的方式会变得很便捷 1. spring 配置文件需要导入 <?xml versio ...
- spring通过静态方法获得properties文件的值
获得spring bean方法 @Component public class BeanUtils implements ApplicationContextAware { private stati ...
- Spring 配置文件中将common.properties文件外置
将配置文件的路径从项目中移出来 1. 在springApplicationContext中 <context:property-placeholder location="file:$ ...
随机推荐
- ZOJ2929 Penalty Kick(概率)
题目挺水的,但由于其独特的阅读量比赛的时候没发现这道水题,在此做一下翻译,如果有人搜到这翻译的话有帮助的话自然最好啦. 中国队平局进入最后的点球决胜局,首先抛硬币决定谁先罚球,然后先是罚五球,如果罚的 ...
- 详解 $_SERVER 函数中QUERY_STRING和REQUEST_URI区别
详解 $_SERVER 函数中QUERY_STRING和REQUEST_URI区别 http://blog.sina.com.cn/s/blog_686999de0100jgda.html 实例: ...
- WCF分布式开发步步为赢(3)WCF服务元数据交换、配置及编程开发
今天我们继续WCF分布式开发步步为赢(3)WCF服务元数据交换.配置及编程开发的学习.经过前面两节的学习,我们了解WCF分布式开发的相关的基本的概念和自定义宿主托管服务的完整的开发和配置过程.今天我们 ...
- UVA 11609 Teams 组合数学+快速幂
In a galaxy far far away there is an ancient game played among the planets. The specialty of the gam ...
- SSH乱码和Xshell异常断开解决方法
一.SSH Secure Shell Client中文乱码的解决方法 这是SSH Secure Shell Client多年未解决的短板,要求客户端和服务器端都要‘UTF-8’编码,我终于知道Wind ...
- proc插入数据到数据库
#include<stdio.h>EXEC SQL INCLUDE SQLCA; void insert (char password_[6],char id_[20],int balan ...
- Linux基础--例行工作
1.仅进行一次的工作排程--at at的工作情况其实是这样的: 1)先找寻/etc/at.allow这个档案,写在这个档案中的使用者才能使用at,没有在这个档案中的使用者则不能使用at(即使没有写在a ...
- 解决yum错误Error: requested datatype primary not available
服务器信息: [mvj3@sdk2 ~]$ cat /proc/version Linux version 2.6.18-194.el5 (mockbuild@ca-build10.us.oracle ...
- 验证工具类 - ValidateUtils.java
验证工具类,提供验证email格式.是否ipv4.是否ipv6.是否中文.是否数字.正则表达式验证的方法. 源码如下:(点击下载 - ValidateUtils.java .commons-lang- ...
- PowerDesigner15.1创建模型及生成带注释sql操作手册
转自:http://blog.csdn.net/huiwenjie168/article/details/7824029 一.创建模型 操作:file-->new Model… 快捷键:ctrl ...