BAEL-2914: Immutable @ConfigurationProperties binding (#8623)
This commit is contained in:
@@ -1,11 +0,0 @@
|
||||
## Spring Boot Dependency Inject
|
||||
|
||||
This module contains articles about dependency injection with Spring Boot
|
||||
|
||||
### The Course
|
||||
The "REST With Spring" Classes: http://bit.ly/restwithspring
|
||||
|
||||
### Relevant Articles:
|
||||
|
||||
- [Spring Component Scanning](https://www.baeldung.com/spring-component-scanning)
|
||||
- [Spring @ComponentScan – Filter Types](https://www.baeldung.com/spring-componentscan-filter-type)
|
||||
@@ -1,64 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>spring-boot-di</artifactId>
|
||||
<name>spring-boot-di</name>
|
||||
<packaging>jar</packaging>
|
||||
<description>Module For Spring Boot DI</description>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-boot-2</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-boot-2</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.aspectj</groupId>
|
||||
<artifactId>aspectjweaver</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-tomcat</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.tomcat.embed</groupId>
|
||||
<artifactId>tomcat-embed-jasper</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<mainClass>com.baeldung.SpringBootDiApplication</mainClass>
|
||||
<layout>JAR</layout>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<start-class>com.baeldung.SpringBootDiApplication</start-class>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
@@ -1,12 +0,0 @@
|
||||
package com.baeldung;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class SpringBootDiApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SpringBootDiApplication.class, args);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package com.baeldung.componentscan;
|
||||
|
||||
public class ExampleBean {
|
||||
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package com.baeldung.componentscan.filter.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
public @interface Animal {
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.baeldung.componentscan.filter.annotation;
|
||||
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.FilterType;
|
||||
|
||||
@Configuration
|
||||
@ComponentScan(includeFilters = @ComponentScan.Filter(type = FilterType.ANNOTATION, classes = Animal.class))
|
||||
public class ComponentScanAnnotationFilterApp {
|
||||
|
||||
public static void main(String[] args) {
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package com.baeldung.componentscan.filter.annotation;
|
||||
|
||||
@Animal
|
||||
public class Elephant {
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
package com.baeldung.componentscan.springapp;
|
||||
|
||||
import com.baeldung.componentscan.ExampleBean;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@ComponentScan
|
||||
// @ComponentScan(excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = Rose.class))
|
||||
// @ComponentScan(basePackages = "com.baeldung.componentscan.springapp")
|
||||
// @ComponentScan(basePackages = "com.baeldung.componentscan.springapp.animals")
|
||||
// @ComponentScan (excludeFilters = @ComponentScan.Filter(type=FilterType.REGEX,pattern="com\\.baeldung\\.componentscan\\.springapp\\.flowers\\..*"))
|
||||
public class SpringComponentScanApp {
|
||||
|
||||
private static ApplicationContext applicationContext;
|
||||
|
||||
@Bean
|
||||
public ExampleBean exampleBean() {
|
||||
return new ExampleBean();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
applicationContext = new AnnotationConfigApplicationContext(SpringComponentScanApp.class);
|
||||
|
||||
for (String beanName : applicationContext.getBeanDefinitionNames()) {
|
||||
System.out.println(beanName);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package com.baeldung.componentscan.springapp.animals;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class Cat {
|
||||
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package com.baeldung.componentscan.springapp.animals;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class Dog {
|
||||
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package com.baeldung.componentscan.springapp.flowers;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class Rose {
|
||||
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
package com.baeldung.componentscan.springbootapp;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
import com.baeldung.componentscan.ExampleBean;
|
||||
|
||||
@SpringBootApplication
|
||||
// @ComponentScan(basePackages = "com.baeldung.componentscan.springbootapp.animals")
|
||||
// @ComponentScan ( excludeFilters = @ComponentScan.Filter(type=FilterType.REGEX,pattern="com\\.baeldung\\.componentscan\\.springbootapp\\.flowers\\..*"))
|
||||
// @ComponentScan(excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = Rose.class))
|
||||
|
||||
public class SpringBootComponentScanApp {
|
||||
private static ApplicationContext applicationContext;
|
||||
|
||||
@Bean
|
||||
public ExampleBean exampleBean() {
|
||||
return new ExampleBean();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
applicationContext = SpringApplication.run(SpringBootComponentScanApp.class, args);
|
||||
checkBeansPresence("cat", "dog", "rose", "exampleBean", "springBootApp");
|
||||
|
||||
}
|
||||
|
||||
private static void checkBeansPresence(String... beans) {
|
||||
for (String beanName : beans) {
|
||||
System.out.println("Is " + beanName + " in ApplicationContext: " + applicationContext.containsBean(beanName));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package com.baeldung.componentscan.springbootapp.animals;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class Cat {
|
||||
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package com.baeldung.componentscan.springbootapp.animals;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class Dog {
|
||||
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package com.baeldung.componentscan.springbootapp.flowers;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class Rose {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user