BAEL-2914: Immutable @ConfigurationProperties binding (#8623)

This commit is contained in:
kwoyke
2020-01-29 07:06:48 +01:00
committed by GitHub
parent 7c047aa647
commit e4256c2cfc
20 changed files with 74 additions and 2 deletions

View File

@@ -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);
}
}

View File

@@ -1,5 +0,0 @@
package com.baeldung.componentscan;
public class ExampleBean {
}

View File

@@ -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 {
}

View File

@@ -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) {
}
}

View File

@@ -1,5 +0,0 @@
package com.baeldung.componentscan.filter.annotation;
@Animal
public class Elephant {
}

View File

@@ -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);
}
}
}

View File

@@ -1,8 +0,0 @@
package com.baeldung.componentscan.springapp.animals;
import org.springframework.stereotype.Component;
@Component
public class Cat {
}

View File

@@ -1,8 +0,0 @@
package com.baeldung.componentscan.springapp.animals;
import org.springframework.stereotype.Component;
@Component
public class Dog {
}

View File

@@ -1,8 +0,0 @@
package com.baeldung.componentscan.springapp.flowers;
import org.springframework.stereotype.Component;
@Component
public class Rose {
}

View File

@@ -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));
}
}
}

View File

@@ -1,8 +0,0 @@
package com.baeldung.componentscan.springbootapp.animals;
import org.springframework.stereotype.Component;
@Component
public class Cat {
}

View File

@@ -1,8 +0,0 @@
package com.baeldung.componentscan.springbootapp.animals;
import org.springframework.stereotype.Component;
@Component
public class Dog {
}

View File

@@ -1,8 +0,0 @@
package com.baeldung.componentscan.springbootapp.flowers;
import org.springframework.stereotype.Component;
@Component
public class Rose {
}