Spring源码-01-调试代码
Spring源码工程下新建模块用于调试源码
一 新建模块
名称以spring为前缀
二 引入依赖
plugins {
id 'java'
}
group 'org.springframework'
version '6.0.3-SNAPSHOT'
repositories {
mavenCentral()
}
dependencies {
api(project(":spring-context"))
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
}
test {
useJUnitPlatform()
}
三 代码
public class Main {
public static void main(String[] args) {
ApplicationContext ctx = new AnnotationConfigApplicationContext(MyConfig.class);
MyBean1 myBean1 = ctx.getBean(MyBean1.class);
String name = myBean1.getName();
System.out.println(name);
}
}
@Configuration
public class MyConfig {
@Bean
public MyBean1 myBean1() {
return new MyBean1();
}
}
class MyBean1 {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
标签:MyBean1,01,name,Spring,class,源码,public,String
From: https://www.cnblogs.com/miss-u/p/16948975.html