[BAEL-16662] Move articles out of spring-core and into spring-di and … (#7750)
* [BAEL-16662] Move articles out of spring-core and into spring-di and spring-core-2 * [BAEL-16662] Fixed required config classes * [BAEL-16662] - Removed unused dependencies from spring-core
This commit is contained in:
committed by
Josh Cummings
parent
6ee7181125
commit
8d6c2dc2ed
@@ -1,3 +1,6 @@
|
||||
## Relevant Articles:
|
||||
|
||||
- [Understanding getBean() in Spring](https://www.baeldung.com/spring-getbean)
|
||||
- [Exploring the Spring BeanFactory API](http://www.baeldung.com/spring-beanfactory)
|
||||
- [How to use the Spring FactoryBean?](http://www.baeldung.com/spring-factorybean)
|
||||
- [Spring – Injecting Collections](http://www.baeldung.com/spring-injecting-collections)
|
||||
|
||||
@@ -14,6 +14,11 @@
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-test</artifactId>
|
||||
<version>${spring.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-beans</artifactId>
|
||||
|
||||
+1
-11
@@ -1,22 +1,12 @@
|
||||
### Relevant Articles:
|
||||
- [Wiring in Spring: @Autowired, @Resource and @Inject](http://www.baeldung.com/spring-annotations-resource-inject-autowire)
|
||||
- [Exploring the Spring BeanFactory API](http://www.baeldung.com/spring-beanfactory)
|
||||
- [How to use the Spring FactoryBean?](http://www.baeldung.com/spring-factorybean)
|
||||
- [Constructor Dependency Injection in Spring](http://www.baeldung.com/constructor-injection-in-spring)
|
||||
- [Constructor Injection in Spring with Lombok](http://www.baeldung.com/spring-injection-lombok)
|
||||
- [Introduction to Spring’s StreamUtils](http://www.baeldung.com/spring-stream-utils)
|
||||
- [XML-Based Injection in Spring](http://www.baeldung.com/spring-xml-injection)
|
||||
- [A Quick Guide to the Spring @Lazy Annotation](http://www.baeldung.com/spring-lazy-annotation)
|
||||
- [Injecting Prototype Beans into a Singleton Instance in Spring](http://www.baeldung.com/spring-inject-prototype-bean-into-singleton)
|
||||
- [@Lookup Annotation in Spring](http://www.baeldung.com/spring-lookup)
|
||||
- [BeanNameAware and BeanFactoryAware Interfaces in Spring](http://www.baeldung.com/spring-bean-name-factory-aware)
|
||||
- [Spring – Injecting Collections](http://www.baeldung.com/spring-injecting-collections)
|
||||
- [Access a File from the Classpath in a Spring Application](http://www.baeldung.com/spring-classpath-file-access)
|
||||
- [Controlling Bean Creation Order with @DependsOn Annotation](http://www.baeldung.com/spring-depends-on)
|
||||
- [Spring Autowiring of Generic Types](https://www.baeldung.com/spring-autowire-generics)
|
||||
- [Spring Application Context Events](https://www.baeldung.com/spring-context-events)
|
||||
- [Unsatisfied Dependency in Spring](https://www.baeldung.com/spring-unsatisfied-dependency)
|
||||
- [What is a Spring Bean?](https://www.baeldung.com/spring-bean)
|
||||
- [Spring PostConstruct and PreDestroy Annotations](https://www.baeldung.com/spring-postconstruct-predestroy)
|
||||
- [Guice vs Spring – Dependency Injection](https://www.baeldung.com/guice-spring-dependency-injection)
|
||||
- [Circular Dependencies in Spring](http://www.baeldung.com/circular-dependencies-in-spring)
|
||||
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
### Relevant Articles
|
||||
|
||||
- [The Spring @Qualifier Annotation](https://www.baeldung.com/spring-qualifier-annotation)
|
||||
- [Constructor Dependency Injection in Spring](http://www.baeldung.com/constructor-injection-in-spring)
|
||||
- [Spring Autowiring of Generic Types](https://www.baeldung.com/spring-autowire-generics)
|
||||
- [Guice vs Spring – Dependency Injection](https://www.baeldung.com/guice-spring-dependency-injection)
|
||||
- [Injecting Prototype Beans into a Singleton Instance in Spring](http://www.baeldung.com/spring-inject-prototype-bean-into-singleton)
|
||||
- [@Lookup Annotation in Spring](http://www.baeldung.com/spring-lookup)
|
||||
- [Controlling Bean Creation Order with @DependsOn Annotation](http://www.baeldung.com/spring-depends-on)
|
||||
- [Unsatisfied Dependency in Spring](https://www.baeldung.com/spring-unsatisfied-dependency)
|
||||
- [Circular Dependencies in Spring](http://www.baeldung.com/circular-dependencies-in-spring)
|
||||
|
||||
+69
-9
@@ -9,18 +9,70 @@
|
||||
<name>spring-di</name>
|
||||
|
||||
<parent>
|
||||
<artifactId>parent-boot-2</artifactId>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-spring-5</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../parent-boot-2</relativePath>
|
||||
<relativePath>../parent-spring-5</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<!-- Spring -->
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-test</artifactId>
|
||||
<version>${spring.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-beans</artifactId>
|
||||
<version>${spring.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context</artifactId>
|
||||
<version>${spring.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.inject</groupId>
|
||||
<artifactId>javax.inject</artifactId>
|
||||
<version>${javax.inject.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>${guava.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
<version>${spring-boot.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-test</artifactId>
|
||||
<version>${mockito.spring.boot.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<version>${assertj.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>${commons.io.version}</version>
|
||||
</dependency>
|
||||
<!-- Spring -->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework</groupId>-->
|
||||
<!-- <artifactId>spring-context</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.annotation</groupId>
|
||||
@@ -28,12 +80,12 @@
|
||||
<version>${annotation-api.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- test scoped -->
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- <!– test scoped –>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework</groupId>-->
|
||||
<!-- <artifactId>spring-test</artifactId>-->
|
||||
<!-- <scope>test</scope>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
</dependencies>
|
||||
|
||||
@@ -97,6 +149,14 @@
|
||||
<!-- Spring -->
|
||||
<org.springframework.version>5.0.6.RELEASE</org.springframework.version>
|
||||
<annotation-api.version>1.3.2</annotation-api.version>
|
||||
|
||||
<mockito.spring.boot.version>1.4.4.RELEASE</mockito.spring.boot.version>
|
||||
<javax.inject.version>1</javax.inject.version>
|
||||
<guava.version>20.0</guava.version>
|
||||
<commons.io.version>2.5</commons.io.version>
|
||||
<spring-boot.version>1.5.2.RELEASE</spring-boot.version>
|
||||
<mockito.version>1.10.19</mockito.version>
|
||||
<assertj.version>3.12.2</assertj.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
+31
-31
@@ -1,31 +1,31 @@
|
||||
package com.baeldung.constructordi;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
||||
import com.baeldung.constructordi.domain.Car;
|
||||
|
||||
public class SpringRunner {
|
||||
public static void main(String[] args) {
|
||||
Car toyota = getCarFromXml();
|
||||
|
||||
System.out.println(toyota);
|
||||
|
||||
toyota = getCarFromJavaConfig();
|
||||
|
||||
System.out.println(toyota);
|
||||
}
|
||||
|
||||
private static Car getCarFromJavaConfig() {
|
||||
ApplicationContext context = new AnnotationConfigApplicationContext(Config.class);
|
||||
|
||||
return context.getBean(Car.class);
|
||||
}
|
||||
|
||||
private static Car getCarFromXml() {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext("constructordi.xml");
|
||||
|
||||
return context.getBean(Car.class);
|
||||
}
|
||||
}
|
||||
package com.baeldung.constructordi;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
||||
import com.baeldung.constructordi.domain.Car;
|
||||
|
||||
public class SpringRunner {
|
||||
public static void main(String[] args) {
|
||||
Car toyota = getCarFromXml();
|
||||
|
||||
System.out.println(toyota);
|
||||
|
||||
toyota = getCarFromJavaConfig();
|
||||
|
||||
System.out.println(toyota);
|
||||
}
|
||||
|
||||
private static Car getCarFromJavaConfig() {
|
||||
ApplicationContext context = new AnnotationConfigApplicationContext(Config.class);
|
||||
|
||||
return context.getBean(Car.class);
|
||||
}
|
||||
|
||||
private static Car getCarFromXml() {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext("constructordi.xml");
|
||||
|
||||
return context.getBean(Car.class);
|
||||
}
|
||||
}
|
||||
+21
-21
@@ -1,21 +1,21 @@
|
||||
package com.baeldung.constructordi.domain;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class Car {
|
||||
private Engine engine;
|
||||
private Transmission transmission;
|
||||
|
||||
@Autowired
|
||||
public Car(Engine engine, Transmission transmission) {
|
||||
this.engine = engine;
|
||||
this.transmission = transmission;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("Engine: %s Transmission: %s", engine, transmission);
|
||||
}
|
||||
}
|
||||
package com.baeldung.constructordi.domain;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class Car {
|
||||
private Engine engine;
|
||||
private Transmission transmission;
|
||||
|
||||
@Autowired
|
||||
public Car(Engine engine, Transmission transmission) {
|
||||
this.engine = engine;
|
||||
this.transmission = transmission;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("Engine: %s Transmission: %s", engine, transmission);
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user