JavaConfig 纯JAVA注解
1、无需配置applicationContext.xml文件
2、被注入类
package com.chris.Dao;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
3、 配置类
package com.chris.pojo;
import com.chris.Dao.UserDao;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
4、测试类
import com.chris.Dao.UserDao;
import com.chris.pojo.appCongfigClass;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
public class MyTest {
public static void main(String[] args) {