component-scan

@SpringBootApplication - ComponentScan does not work as intended in new Eclipse project

…衆ロ難τιáo~ 提交于 2021-02-10 06:01:49
问题 I recently started using Eclipse (moved from IntelliJ Idea) but whatever new SpringBoot app I start writing, I always get this problem. The @SpringBootApplication on my main class does not work as intended. I should be able to get away without adding the @ComponentScann annotation (I know it would make it work), but the intention of this post is to find out the route cause of the original failure. I already know work-arounds. My app always breaks with the following error message: . ____ _ __

Spring: Why is @PreDestroy not called at end of each test class?

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-08 20:52:06
问题 I have an integration test class annotated as follows @WebAppConfiguration @ContextConfiguration(classes = {AppConfiguration.class}) @RunWith(SpringJUnit4ClassRunner.class) public class CacheConsumerTest { } Here's my AppConfiguration @Configuration @ComponentScan(basePackages = {"com.etc.etc.etc."}) @EnableWebMvc public class AppConfiguration { } For some reason, none of my @Component beans' @PreDestroy is getting called at the end of all tests in CacheConsumerTest . @PostConstruct is

How is @ConfigurationProperties-annotated classes detected automatically with @SpringBootApplication Annotation

…衆ロ難τιáo~ 提交于 2021-02-08 11:36:02
问题 I am learning Spring Boot and have a question with one example in the reference documentation. Following section of the documentation mentions 6. Using the @SpringBootApplication Annotation A single @SpringBootApplication annotation can be used to enable those three features, that is: @EnableAutoConfiguration: enable Spring Boot’s auto-configuration mechanism @ComponentScan: enable @Component scan on the package where the application is located (see the best practices) @Configuration: allow

Spring boot auto configuration with dependency and without @ComponentScan

女生的网名这么多〃 提交于 2021-01-20 20:12:32
问题 Spring boot provides @ComponentScan to find packages to be scanned. I am building a library which has @RestControllers inside with package com.mylib.controller . There are other classes as well with stereotype annotations in different packages. So, if some one is developing SpringBoot Application with com.myapp base package. He uses my library in his application. He need to mention @ComponentScan("com.mylib") to discover stereotype components of library. Is there any way to scan components

Spring boot auto configuration with dependency and without @ComponentScan

十年热恋 提交于 2021-01-20 20:10:34
问题 Spring boot provides @ComponentScan to find packages to be scanned. I am building a library which has @RestControllers inside with package com.mylib.controller . There are other classes as well with stereotype annotations in different packages. So, if some one is developing SpringBoot Application with com.myapp base package. He uses my library in his application. He need to mention @ComponentScan("com.mylib") to discover stereotype components of library. Is there any way to scan components

Spring custom @Enable annotation meta-annotated with @ComponentScan

岁酱吖の 提交于 2020-05-26 05:30:30
问题 I'm trying to write my own @Enable annotation for Spring framework, which should be used as follows: package com.example.package.app; @SpringBootApplication @com.example.annotations.EnableCustom("com.example.package.custom") public class MyApplication {} I followed Component scan using custom annotation, but this poses several limitations: I cannot make the base package property dynamic, i.e. I cannot pass "com.example.package.base" , but need to pre-define the package at the configuration. I

Spring custom @Enable annotation meta-annotated with @ComponentScan

不打扰是莪最后的温柔 提交于 2020-05-26 05:30:16
问题 I'm trying to write my own @Enable annotation for Spring framework, which should be used as follows: package com.example.package.app; @SpringBootApplication @com.example.annotations.EnableCustom("com.example.package.custom") public class MyApplication {} I followed Component scan using custom annotation, but this poses several limitations: I cannot make the base package property dynamic, i.e. I cannot pass "com.example.package.base" , but need to pre-define the package at the configuration. I

Spring custom @Enable annotation meta-annotated with @ComponentScan

旧巷老猫 提交于 2020-05-26 05:29:45
问题 I'm trying to write my own @Enable annotation for Spring framework, which should be used as follows: package com.example.package.app; @SpringBootApplication @com.example.annotations.EnableCustom("com.example.package.custom") public class MyApplication {} I followed Component scan using custom annotation, but this poses several limitations: I cannot make the base package property dynamic, i.e. I cannot pass "com.example.package.base" , but need to pre-define the package at the configuration. I

Spring Boot: autowire beans from library project

元气小坏坏 提交于 2020-04-05 09:13:37
问题 I'm struggling to autowire beans from my custom library, imported with gradle. after reading couple of similar topics I am still unable to find solution. I have Spring Boot project that depends on other project(my custom library with Components, Repositories etc...). This library is a Spring non-runnable jar, that consists primarily from domain Entities and Repositories. It doesn't have runnable Application.class and any properties... When I starting the application I can see that My

Spring Boot: autowire beans from library project

我们两清 提交于 2020-04-05 09:12:10
问题 I'm struggling to autowire beans from my custom library, imported with gradle. after reading couple of similar topics I am still unable to find solution. I have Spring Boot project that depends on other project(my custom library with Components, Repositories etc...). This library is a Spring non-runnable jar, that consists primarily from domain Entities and Repositories. It doesn't have runnable Application.class and any properties... When I starting the application I can see that My