Does a class annotated with @Configuration
not implement the SpringProxy
interface?
test:
@Configuration
public class TestConfigurationClass {
}
and
@Component
public class TestComponentClass {
@Transactional
public void methods(){
}
}
and
@SpringBootTest
class DemoApplicationTests {
@Autowired
TestConfigurationClass testConfigurationClass;
@Autowired
TestComponentClass testComponentClass;
@Test
void contextLoads() {
Assertions.assertTrue(testComponentClass instanceof SpringProxy); //true
Assertions.assertTrue(testConfigurationClass instanceof SpringProxy); //false
}
}
Comment From: jhoeller
The SpringProxy
interface is exclusively for AOP proxies, not for any kind of runtime subclassing. Configuration classes and lookup methods lead to a runtime subclass that replaces the original class, so technically not a proxy but rather a substitute.
If you'd like to determine the original class for any kind of CGLIB-generated subclass, consider ClassUtils.getUserClass
instead.