利用@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文件的更多相关文章

  1. Java中如何获取spring中配置的properties文件内容

    有2种方式: 一. 1.通过spring配置properties文件 [java]  <bean id="propertyConfigurer"      class=&qu ...

  2. JdbcTemplae使用入门&&Spring三种连接池配置&&Spring配置文件引用外部properties文件

    JdbcTemplate的使用 Spring为了各种支持的持久化技术,都提供了简单操作的模版和回调. JdbcTemplate 简化 JDBC 操作HibernateTemplate 简化 Hiber ...

  3. spring 配置文件中使用properties文件 配置

    配置Bean载入properties文件: <bean id="propertyPlaceholderConfigurer" class="org.springfr ...

  4. 解密Spring加载的Properties文件

    Spring的框架中,org.springframework.beans.factory.config.PropertyPlaceholderConfigurer类可以将.properties(key ...

  5. 在Spring环境下存取properties文件…

    Spring中PropertyPlaceholderConfigurer的使用 (1) 基本的使用方法是 classpath:/spring/include/dbQuery.properties 其中 ...

  6. Spring MVC 中使用properties文件

    首先要搭建Spring mvc的环境,然后开始properties文件里的配置: 第一步:在springcontext中注入properties,具体路径自己调整 <bean id=" ...

  7. Spring 通过配置文件注入 properties文件

    当我们需要将某些值放入 properties文件 key=value 的方式,获取文件信息使用spring 注入的方式会变得很便捷 1. spring 配置文件需要导入 <?xml versio ...

  8. spring通过静态方法获得properties文件的值

    获得spring bean方法 @Component public class BeanUtils implements ApplicationContextAware { private stati ...

  9. Spring 配置文件中将common.properties文件外置

    将配置文件的路径从项目中移出来 1. 在springApplicationContext中 <context:property-placeholder location="file:$ ...

随机推荐

  1. (转)Android学习进阶路线导航线路(Android源码分享)

     转载请注明出处:http://blog.csdn.net/qinjuning 前言:公司最近来了很多应届实习生,看着他们充满信心但略带稚气的脸庞上,想到了去年的自己,那是的我是不是也和 现在的他们一 ...

  2. 《JavaScript基础教程(第8版)》PDF

    简介:JavaScript基础教程(第8版)循序渐进地讲述了JavaScript及相关的CSS.DOM.Ajax.jQuery等技术.书中从JavaScript语言基础开始,分别讨论了图像.框架.浏览 ...

  3. 有N个大小不等的自然数(1--N),请将它们由小到大排序。要求程序算法:时间复杂度为O(n),空间复杂度为O(1)。

    #include<stdio.h> int main() { ]={,,,,,,,,}; int i,tmp; ;i<;i++) { ) { tmp=a[i]; a[i]=a[a[i ...

  4. java web线程池

    线程池 要知道在计算机中任何资源的创建,包括线程,都需要消耗系统资源的.在WEB服务中,对于web服 务器的响应速度必须要尽可能的快,这就容不得每次在用户提交请求按钮后,再创建线程提供服务 .为了减少 ...

  5. iOS开发--CornerStone上传静态库(.a文件)

    首先打开软件左上角 CornerStone-Preferences-SubVersion 第一个地方把对号去掉,第二个地方把.a那个删除,然后save. 然后把你的.a文件放到本地的相应文件夹下, 但 ...

  6. mysql 常用命令(备忘)

    1:使用SHOW语句找出在服务器上当前存在什么数据库: mysql> SHOW DATABASES; 2:2.创建一个数据库MYSQLDATA mysql> CREATE DATABASE ...

  7. uchome 积分体系

    一.总体流程 1):管理员在后台修改积分规则2):数据被写入数据表creditrule 中,并将数据写入缓存文件data/data_creditrule.php 中3):用户发表文章或者进行其他操作的 ...

  8. 295. Find Median from Data Stream

    题目: Median is the middle value in an ordered integer list. If the size of the list is even, there is ...

  9. VNC常用操作及常见问题解决办法汇总

    VNC登录用户缺省是root,但在安装oracle时必须用oracle用户的身份登录,下面我们就以oracle为例说明如何配置VNC,从而可以使用不同的用户登录到主机.步骤描述如下:    步骤一:修 ...

  10. javascript Klass 实现

    var Klass=function(Parent,props){ var Child,F,i; Child=function(){ if(Child.uber && Child.ub ...