인프런 커뮤니티 질문&답변

강재은님의 프로필 이미지
강재은

작성한 질문수

스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술

org.springframework.beans.factory.BeanCreationException 오류

작성

·

1.3K

0

AOP 적용 목차 전까지는 서버 실행해도 문제 없는데 AOP 적용 예제 넣고 돌리면 아래 에러 코드가 뜨네요..

바로 TimeTraceAop.java 를 넣자마자 BeanCreationException 이 에러가 나오는데 어떻게 해야되죠?

이 에러가 나오는 프로젝트 링크도 같이 올렸습니다..

https://drive.google.com/file/d/1j-eePhGfYIg5oH3p5croYcFI6IhNN4RP/view?usp=sharing

 

에러 코드

----------------------------------------------------

START :execution(MemberService hello.hellospring.SpringConfig.memberService())

END :execution(MemberService hello.hellospring.SpringConfig.memberService()) 27ms

2022-08-10 20:22:50.081  WARN 16904 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'memberController' defined in file [C:\Users\36912\Desktop\hello-spring\hello-spring\out\production\classes\hello\hellospring\controller\MemberController.class]: Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class hello.hellospring.controller.MemberController: Common causes of this problem include using a final class or a non-visible class; nested exception is java.lang.IllegalArgumentException: No visible constructors in class hello.hellospring.controller.MemberController

2022-08-10 20:22:50.082  INFO 16904 --- [           main] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'

2022-08-10 20:22:50.087  INFO 16904 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown initiated...

2022-08-10 20:22:50.109  INFO 16904 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown completed.

2022-08-10 20:22:50.111  INFO 16904 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]

2022-08-10 20:22:50.127  INFO 16904 --- [           main] ConditionEvaluationReportLoggingListener : 

 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.

2022-08-10 20:22:50.173 ERROR 16904 --- [           main] o.s.boot.SpringApplication               : Application run failed

 

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'memberController' defined in file [C:\Users\36912\Desktop\hello-spring\hello-spring\out\production\classes\hello\hellospring\controller\MemberController.class]: Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class hello.hellospring.controller.MemberController: Common causes of this problem include using a final class or a non-visible class; nested exception is java.lang.IllegalArgumentException: No visible constructors in class hello.hellospring.controller.MemberController

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:628) ~[spring-beans-5.3.20.jar:5.3.20]

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.20.jar:5.3.20]

at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.20.jar:5.3.20]

at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.20.jar:5.3.20]

at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.20.jar:5.3.20]

at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.20.jar:5.3.20]

at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:953) ~[spring-beans-5.3.20.jar:5.3.20]

at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) ~[spring-context-5.3.20.jar:5.3.20]

at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.20.jar:5.3.20]

at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147) ~[spring-boot-2.7.0.jar:2.7.0]

at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734) ~[spring-boot-2.7.0.jar:2.7.0]

at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408) ~[spring-boot-2.7.0.jar:2.7.0]

at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) ~[spring-boot-2.7.0.jar:2.7.0]

at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306) ~[spring-boot-2.7.0.jar:2.7.0]

at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295) ~[spring-boot-2.7.0.jar:2.7.0]

at hello.hellospring.HelloSpringApplication.main(HelloSpringApplication.java:9) ~[classes/:na]

Caused by: org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class hello.hellospring.controller.MemberController: Common causes of this problem include using a final class or a non-visible class; nested exception is java.lang.IllegalArgumentException: No visible constructors in class hello.hellospring.controller.MemberController

at org.springframework.aop.framework.CglibAopProxy.getProxy(CglibAopProxy.java:209) ~[spring-aop-5.3.20.jar:5.3.20]

at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:110) ~[spring-aop-5.3.20.jar:5.3.20]

at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.createProxy(AbstractAutoProxyCreator.java:480) ~[spring-aop-5.3.20.jar:5.3.20]

at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:344) ~[spring-aop-5.3.20.jar:5.3.20]

at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:293) ~[spring-aop-5.3.20.jar:5.3.20]

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:455) ~[spring-beans-5.3.20.jar:5.3.20]

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1808) ~[spring-beans-5.3.20.jar:5.3.20]

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) ~[spring-beans-5.3.20.jar:5.3.20]

... 15 common frames omitted

Caused by: java.lang.IllegalArgumentException: No visible constructors in class hello.hellospring.controller.MemberController

at org.springframework.cglib.proxy.Enhancer.filterConstructors(Enhancer.java:763) ~[spring-core-5.3.20.jar:5.3.20]

at org.springframework.cglib.proxy.Enhancer.generateClass(Enhancer.java:662) ~[spring-core-5.3.20.jar:5.3.20]

at org.springframework.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25) ~[spring-core-5.3.20.jar:5.3.20]

at org.springframework.cglib.core.ClassLoaderAwareGeneratorStrategy.generate(ClassLoaderAwareGeneratorStrategy.java:57) ~[spring-core-5.3.20.jar:5.3.20]

at org.springframework.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:358) ~[spring-core-5.3.20.jar:5.3.20]

at org.springframework.cglib.proxy.Enhancer.generate(Enhancer.java:585) ~[spring-core-5.3.20.jar:5.3.20]

at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:110) ~[spring-core-5.3.20.jar:5.3.20]

at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:108) ~[spring-core-5.3.20.jar:5.3.20]

at org.springframework.cglib.core.internal.LoadingCache$2.call(LoadingCache.java:54) ~[spring-core-5.3.20.jar:5.3.20]

at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na]

at org.springframework.cglib.core.internal.LoadingCache.createEntry(LoadingCache.java:61) ~[spring-core-5.3.20.jar:5.3.20]

at org.springframework.cglib.core.internal.LoadingCache.get(LoadingCache.java:34) ~[spring-core-5.3.20.jar:5.3.20]

at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData.get(AbstractClassGenerator.java:134) ~[spring-core-5.3.20.jar:5.3.20]

at org.springframework.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:319) ~[spring-core-5.3.20.jar:5.3.20]

at org.springframework.cglib.proxy.Enhancer.createHelper(Enhancer.java:572) ~[spring-core-5.3.20.jar:5.3.20]

at org.springframework.cglib.proxy.Enhancer.createClass(Enhancer.java:419) ~[spring-core-5.3.20.jar:5.3.20]

at org.springframework.aop.framework.ObjenesisCglibAopProxy.createProxyClassAndInstance(ObjenesisCglibAopProxy.java:57) ~[spring-aop-5.3.20.jar:5.3.20]

at org.springframework.aop.framework.CglibAopProxy.getProxy(CglibAopProxy.java:206) ~[spring-aop-5.3.20.jar:5.3.20]

... 22 common frames omitted

 

 

종료 코드 1(으)로 완료된 프로세스

----------------------------------------------------

 

답변 1

1

안녕하세요. 강재은님, 공식 서포터즈 OMG입니다.

Could not generate CGLIB subclass of class hello.hellospring.controller.MemberController: Common causes of this problem include using a final class or a non-visible class; nested exception is java.lang.IllegalArgumentException: No visible constructors in class hello.hellospring.controller.MemberControlle

위 에러 메시지가 문제 해결의 힌트입니다.

 


생성자가 private  접근제어자로 되어 있습니다. public으로 변경해주세요.

private MemberController(MemberService memberService){
this.memberService = memberService;
}

 

감사합니다.

감사합니다

강재은님의 프로필 이미지
강재은

작성한 질문수

질문하기