(1)自动装配 开启ComponentScan(自动扫描), 通过在类使用注解@Component(默认bean id为类名第一个字符小写), 使用@Autowired实现属性,构造函数,成员函数的自动装配. @Qulifer注解可以明确指定bean的id解决歧义性. (2)javaconfig装配 ...
分类:
编程语言 时间:
2016-09-17 16:18:53
阅读次数:
203
1.1介绍自从structs2出现上次的漏洞以后,对spring的关注度开始越来越浓。以前spring开发需要配置一大堆的xml,后台spring加入了annotaion,使得xml配置简化了很多,当然还是有些配置需要使用xml,比如申明componentscan等。前段时间发现了spring开了一个新的modelspringboot,主..
分类:
编程语言 时间:
2016-06-04 01:55:41
阅读次数:
457
下面是配置文件,配置了spring的扫描路径,不配置这个注解不起作用。Java代码packagecom.expect.oa.config;importorg.springframework.context.annotation.ComponentScan;importorg.springframework.context.annotation.Configuration;@Configuration@ComponentScan("com.expec..
分类:
编程语言 时间:
2016-05-13 05:18:05
阅读次数:
182
@ComponentScan, @EntityScan or @SpringBootApplication
We generally
recommend that you locate your main application class in a root package above other classes. The @EnableAutoConfiguration annotat...
分类:
编程语言 时间:
2016-05-12 12:36:15
阅读次数:
203
1.自动化配置
package com.springinaction.test;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration//告诉spring这是一个配置类
@C...
分类:
编程语言 时间:
2016-05-07 10:53:57
阅读次数:
151
一、@ComponentScan 1. @Configuration //说明此类是配置文件 @ComponentScan //开启扫描,会扫描当前类的包及其子包 public class CDPlayerConfig { } 2. @ComponentScan(basePackages={"sou
分类:
编程语言 时间:
2016-03-01 16:01:51
阅读次数:
331