diff --git a/Java/spring/ioc/ioc/build.gradle b/Java/spring/ioc/ioc/build.gradle new file mode 100644 index 0000000..bf71689 --- /dev/null +++ b/Java/spring/ioc/ioc/build.gradle @@ -0,0 +1,25 @@ +plugins { + id 'java' + id 'org.springframework.boot' version '3.1.4' + id 'io.spring.dependency-management' version '1.1.3' +} + +group = 'com.example' +version = '0.0.1-SNAPSHOT' + +java { + sourceCompatibility = '17' +} + +repositories { + mavenCentral() +} + +dependencies { + implementation 'org.springframework.boot:spring-boot-starter' + testImplementation 'org.springframework.boot:spring-boot-starter-test' +} + +tasks.named('test') { + useJUnitPlatform() +} diff --git a/Java/spring/ioc/ioc/settings.gradle b/Java/spring/ioc/ioc/settings.gradle new file mode 100644 index 0000000..ad39605 --- /dev/null +++ b/Java/spring/ioc/ioc/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'ioc' diff --git a/Java/spring/ioc/ioc/src/main/java/com/example/ioc/BeanChild.java b/Java/spring/ioc/ioc/src/main/java/com/example/ioc/BeanChild.java new file mode 100644 index 0000000..9828647 --- /dev/null +++ b/Java/spring/ioc/ioc/src/main/java/com/example/ioc/BeanChild.java @@ -0,0 +1,5 @@ +@Component +public class BeanChild { + public int i; + public int BeanParent; +} diff --git a/Java/spring/ioc/ioc/src/main/java/com/example/ioc/BeanConfiguration.java b/Java/spring/ioc/ioc/src/main/java/com/example/ioc/BeanConfiguration.java new file mode 100644 index 0000000..9eb7a08 --- /dev/null +++ b/Java/spring/ioc/ioc/src/main/java/com/example/ioc/BeanConfiguration.java @@ -0,0 +1,8 @@ +@Configuration +@ComponentScan(basePackageClasses = BeanChild.class) +public class BeanConfiguration { + @Bean + public BeanParent getBeanParent() { + return new BeanParent(2000); + } +} diff --git a/Java/spring/ioc/ioc/src/main/java/com/example/ioc/BeanParent.java b/Java/spring/ioc/ioc/src/main/java/com/example/ioc/BeanParent.java new file mode 100644 index 0000000..4b62329 --- /dev/null +++ b/Java/spring/ioc/ioc/src/main/java/com/example/ioc/BeanParent.java @@ -0,0 +1,3 @@ +public class BeanParent { + public int h; +} diff --git a/Java/spring/ioc/ioc/src/main/java/com/example/ioc/IocApplication.java b/Java/spring/ioc/ioc/src/main/java/com/example/ioc/IocApplication.java new file mode 100644 index 0000000..3ebff43 --- /dev/null +++ b/Java/spring/ioc/ioc/src/main/java/com/example/ioc/IocApplication.java @@ -0,0 +1,14 @@ +package com.example.ioc; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class IocApplication { + + public static void main(String[] args) { + BeanChild c = new BeanChild(); + SpringApplication.run(IocApplication.class, args); + } + +} diff --git a/Java/spring/ioc/ioc/src/main/resources/application.properties b/Java/spring/ioc/ioc/src/main/resources/application.properties new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/Java/spring/ioc/ioc/src/main/resources/application.properties @@ -0,0 +1 @@ + diff --git a/Java/spring/ioc/ioc/src/test/java/com/example/ioc/IocApplicationTests.java b/Java/spring/ioc/ioc/src/test/java/com/example/ioc/IocApplicationTests.java new file mode 100644 index 0000000..b3cba8e --- /dev/null +++ b/Java/spring/ioc/ioc/src/test/java/com/example/ioc/IocApplicationTests.java @@ -0,0 +1,13 @@ +package com.example.ioc; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class IocApplicationTests { + + @Test + void contextLoads() { + } + +}