spring注解开发AnnotationConfigApplicationContext的使用
使用AnnotationConfigApplicationContext可以实现基于Java的配置类加载Spring的应用上下文。避免使用application.xml进行配置。相比XML配置,更加便捷。pom引入依赖:org.springframeworkspring-context5.1.7.RELEASEAppConfig.javapackage com.kaigejava.con
使用AnnotationConfigApplicationContext可以实现基于Java的配置类加载Spring的应用上下文。避免使用application.xml进行配置。相比XML配置,更加便捷。
pom引入依赖:
org.springframeworkspring-context5.1.7.RELEASE
AppConfig.java
package com.kaigejava.config;
import com.kaigejava.Entitlement;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class AppConfig {
@Bean(name="entitlement")
public Entitlement entitlement() {
Entitlement ent= new Entitlement();
ent.setName("Entitlement");
ent.setTime(1);
return ent;
}
原创不易,完成人机校验,阅读全文
相关推荐
工作小总结&小工具类记录在Spring boot项目中使用@Async注解,但是没有生效的排查。学习笔录-SPRING BOOTspring boot自动注解引发的错误HM_LEADNEWSSpring boot 基于注解方式配置datasourceSHIRO学习系列使用spring的AOP时候,想要过滤掉某些路径或者忽略指定注解,怎么做?自定义注解Java中注解学习系列教程-4 使用自定义注解实现excel导出HM_LEADNEWSSpring注解配置和xml配置优缺点比较学习笔录-SPRING BOOTspring boot框架学习之重要注解3注解方式读取外部资源配置文件学习笔录-SPRING BOOTspring boot框架学习5-spring boot的web开发(1)