在spring 3.0中的@value
中的文件,进行键值对的注入,例子如下:
1 首先在applicationContext.xml中加入:
<beans xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.1.xsd">
</beans>
的命名空间,然后
2
<util:properties id="settings" location="WEB-INF/classes/META-INF/spring/test.properties" />
3 创建test.properties
abc=123
4
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@RequestMapping("/admin/images")
@Controller
public class ImageAdminController {
private String imageDir;
@Value("#{settings['test.abc']}")
public void setImageDir(String val) {
this.imageDir = val;
}
}
这样就将test.abc的值注入了imageDir中了
在spring 3.0中的@value的更多相关文章
- Spring Boot2.0+中,自定义配置类扩展springMVC的功能
在spring boot1.0+,我们可以使用WebMvcConfigurerAdapter来扩展springMVC的功能,其中自定义的拦截器并不会拦截静态资源(js.css等). @Configur ...
- Spring 4.0 中的 WebSocket 架构
两年前,客户端与服务器端的全双工双向通信作为一个很重要的功能被纳入到WebSocket RFC 6455协议中.在HTML5中,WebSocket已经成为一个流行词,大家对这个功能赋予很多构想,很多时 ...
- 【redis】在spring boot2.0中使用redis的StringRedisTemplate 自动注入@Autowired
1.使用opv.increment 达到增量的效果[判断某个用户 是第几次做这种操作] @RequestMapping("createCode") @RestController ...
- Spring.Net在Mvc4.0中应用的说明
案例Demo:http://yunpan.cn/cJ5aZrm7Uybi3 访问密码 414b Spring.Net在Mvc4.0中应用的说明 1.引用dll 2.修改Global文件 (Spring ...
- 【spring cloud】在spring cloud服务中,打包ms-core失败,报错Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.0.4.RELEASE:repackage (default) on project
在spring cloud服务中,有一个ms-code项目,只为所有的微服务提供核心依赖和工具类,没有业务意义,作为核心依赖使用.所以没有main方法,没有启动类. 在spring cloud整体打包 ...
- 对Maven、gradle、svn、spring 3.0 fragment、git的想法
1.Maven Maven可以构建项目,采用pom方式配置主项目和其他需要引用的项目.同时可结合spring3.0的新特性web fragment. 从现实出发,特别是对于管理不到位,程序员整体素质 ...
- Spring 3.0 AOP (一)AOP 术语
关于AOP.之前我已写过一个系列的随笔: <自己实现简单的AOP>,它的关注点在于实现.实现语言是C#,实现方式为 自定义实现 RealProxy 抽象类.重写Invoke方法,以便进行方 ...
- spring 3.0 应用springmvc 构造RESTful URL 详细讲解
在线springmvc_rest demo 由于下一版本的rapid-framwork需要集成spring RESTful URL,所以研究了一下怎么搭建. 并碰到了一下问题. springmvc 3 ...
- 详解 Spring 3.0 基于 Annotation 的依赖注入实现(转)
使用 @Repository.@Service.@Controller 和 @Component 将类标识为 Bean Spring 自 2.0 版本开始,陆续引入了一些注解用于简化 Spring 的 ...
随机推荐
- ssh The authenticity of host 192.168.0.xxx can't be established
用ssh登录一个机器(换过ip地址),提示输入yes后,屏幕不断出现y,只有按ctrl + c结束 错误是:The authenticity of host 192.168.0.xxx can't b ...
- hdu1501 Zipper
Zipper Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other) Total Submis ...
- elasticsearch 使用事项
template的使用 刚开始的时候,每次实验都去改/etc/elasticsearch/elasticsearch.yml配置文件.事实上在template里修改settings更方便而且灵活!当 ...
- Python -- Web -- WSGI
WSGI:Web Server Gateway Interface 只要求Web开发者实现一个函数,就可以响应HTTP请求. # hello.py def application(environ, s ...
- HDU 5739 Fantasia
可以将这个图转换成森林来进行树形dp求解.看了这篇具体教学才会的:http://www.cnblogs.com/WABoss/p/5696926.html 大致思路:求解一下点双连通分量(Tarjan ...
- Android Studio的使用(八)--// TODO代码
我们都知道Eclipse存在// TODO代码,该段代码在方法中用于标识该方法仍未完成,也可以用于作为该方法的一个快捷键.例如我们可以用于标识onClick()方法,当我们需要查找onClick()方 ...
- Sphinx配置过程
http://www.oschina.net/question/84274_11938 http://www.ibm.com/developerworks/library/os-php-sphinxs ...
- WebSphere MQ 入门指南【转】
WebSphere MQ 入门指南 转自 WebSphere MQ 入门指南 - 大CC - 博客园http://www.cnblogs.com/me115/p/3456407.html 这是一篇入门 ...
- Ubuntu Linux系统下的SVN客户端工具PySVN
在Windows下面一直在用TortoiseSVN做为SVN客户端工具,但它居然没提供Linux版本,无视Linux用户的存在.它视我如空 气,偶视它如废土.开始探索尝试其他跨平台的SVN客户端,最后 ...
- led.c驱动框架2nd
led.c: #include <linux/module.h> #include <linux/init.h> #include <linux/fs.h> ; v ...