강의

멘토링

커뮤니티

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

youngyou1324님의 프로필 이미지
youngyou1324

작성한 질문수

BeanCreationException 에러

작성

·

225

0

강의를 따라서 해보던 중
ProxyFactoryConfigV1 까진 잘 실행이 되는데
ProxyFactoryConfigV2부터 아래와 같은 에러가 나서 문의 드립니다.
코드 오타가 있을까봐 제공해주신 소스 코드 ProxyFactoryConfigV2.java와 ProxyApplication.java를 그대로 복사해서 왔지만 잘 안되네요
 
아래는 제 소스입니다.
 
https://github.com/YoungKyonYou/Proxy-Study
 
"C:\Program Files\Java\jdk-11.0.13\bin\java.exe" -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote -Dspring.jmx.enabled=true -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2021.3.2\lib\idea_rt.jar=50809:C:\Program Files\JetBrains\IntelliJ IDEA 2021.3.2\bin" -Dfile.encoding=UTF-8 -classpath C:\Users\young\proxy-start\build\classes\java\main;C:\Users\young\proxy-start\build\resources\main;C:\Users\young\.gradle\caches\modules-2\files-2.1\org.projectlombok\lombok\1.18.20\18bcea7d5df4d49227b4a0743a536208ce4825bb\lombok-1.18.20.jar;C:\Users\young\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-web\2.5.5\c09bf133d22c865d6ce4d67ff48aece7ff1defb1\spring-boot-starter-web-2.5.5.jar;C:\Users\young\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-json\2.5.5\11923b2b5ca33c6c849952ed1bd47a77c9ec0a85\spring-boot-starter-json-2.5.5.jar;C:\Users\young\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter\2.5.5\8657d6f1f00002e8a839fc35fe2f2cd7fc09b72a\spring-boot-starter-2.5.5.jar;C:\Users\young\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-tomcat\2.5.5\3fb58add8060ff5a6a17e08eeabca1e823c2f04a\spring-boot-starter-tomcat-2.5.5.jar;C:\Users\young\.gradle\caches\modules-2\files-2.1\org.springframework\spring-webmvc\5.3.10\d8a26ccc0fb4788c05eca148be8ee987d554a9d2\spring-webmvc-5.3.10.jar;C:\Users\young\.gradle\caches\modules-2\files-2.1\org.springframework\spring-web\5.3.10\31984cef4b5d38f2711cf870994c43e89619ff4e\spring-web-5.3.10.jar;C:\Users\young\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.datatype\jackson-datatype-jsr310\2.12.5\a0a9870b681a72789c5c6bdc380e45ab719c6aa3\jackson-datatype-jsr310-2.12.5.jar;C:\Users\young\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.module\jackson-module-parameter-names\2.12.5\2c85c2036d0851425a260c01eb5f7ddbed1eeb00\jackson-module-parameter-names-2.12.5.jar;C:\Users\young\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.datatype\jackson-datatype-jdk8\2.12.5\6b2f79547d217ad50dfc5b57af7444a3aa583b43\jackson-datatype-jdk8-2.12.5.jar;C:\Users\young\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-databind\2.12.5\b064cf057f23d3d35390328c5030847efeffedde\jackson-databind-2.12.5.jar;C:\Users\young\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-autoconfigure\2.5.5\350511c5612eea8df4ef0f95e2c1b3ff3ea962e8\spring-boot-autoconfigure-2.5.5.jar;C:\Users\young\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot\2.5.5\c6335b6e1aff79b13565890ad833bb8865ae2d50\spring-boot-2.5.5.jar;C:\Users\young\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-logging\2.5.5\2731a074593f6b1089060a4af54ef8eee464d7f0\spring-boot-starter-logging-2.5.5.jar;C:\Users\young\.gradle\caches\modules-2\files-2.1\jakarta.annotation\jakarta.annotation-api\1.3.5\59eb84ee0d616332ff44aba065f3888cf002cd2d\jakarta.annotation-api-1.3.5.jar;C:\Users\young\.gradle\caches\modules-2\files-2.1\org.springframework\spring-core\5.3.10\4e0b94b1e2d7a7399ecedef03dd676c34133625e\spring-core-5.3.10.jar;C:\Users\young\.gradle\caches\modules-2\files-2.1\org.yaml\snakeyaml\1.28\7cae037c3014350c923776548e71c9feb7a69259\snakeyaml-1.28.jar;C:\Users\young\.gradle\caches\modules-2\files-2.1\org.apache.tomcat.embed\tomcat-embed-websocket\9.0.53\e73e461aa0da6a1779bba31f90011cfbd4e4233\tomcat-embed-websocket-9.0.53.jar;C:\Users\young\.gradle\caches\modules-2\files-2.1\org.apache.tomcat.embed\tomcat-embed-core\9.0.53\3343c5ebe9e66da2f75436569e371920e8db1d55\tomcat-embed-core-9.0.53.jar;C:\Users\young\.gradle\caches\modules-2\files-2.1\org.apache.tomcat.embed\tomcat-embed-el\9.0.53\d2fcc31c3ffad7227fcb14ebffc1ed1ab8b7494\tomcat-embed-el-9.0.53.jar;C:\Users\young\.gradle\caches\modules-2\files-2.1\org.springframework\spring-context\5.3.10\45945cec4c23de39faf98139ad81b59965014ff0\spring-context-5.3.10.jar;C:\Users\young\.gradle\caches\modules-2\files-2.1\org.springframework\spring-aop\5.3.10\de0e0c07193697df7ba5db6086020447fdbcb24d\spring-aop-5.3.10.jar;C:\Users\young\.gradle\caches\modules-2\files-2.1\org.springframework\spring-beans\5.3.10\1ff16eb107dd0411deaffa236467efed44d65c60\spring-beans-5.3.10.jar;C:\Users\young\.gradle\caches\modules-2\files-2.1\org.springframework\spring-expression\5.3.10\7ca7f1b5f7a2a9e335f45ffaeb59995c8ab344bc\spring-expression-5.3.10.jar;C:\Users\young\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-annotations\2.12.5\52d929d5bb21d0186fe24c09624cc3ee4bafc3b3\jackson-annotations-2.12.5.jar;C:\Users\young\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-core\2.12.5\725e364cc71b80e60fa450bd06d75cdea7fb2d59\jackson-core-2.12.5.jar;C:\Users\young\.gradle\caches\modules-2\files-2.1\ch.qos.logback\logback-classic\1.2.6\b09efa852337fa0dd9859614389eec58dc287116\logback-classic-1.2.6.jar;C:\Users\young\.gradle\caches\modules-2\files-2.1\org.apache.logging.log4j\log4j-to-slf4j\2.14.1\ce8a86a3f50a4304749828ce68e7478cafbc8039\log4j-to-slf4j-2.14.1.jar;C:\Users\young\.gradle\caches\modules-2\files-2.1\org.slf4j\jul-to-slf4j\1.7.32\8a055c04ab44e8e8326901cadf89080721348bdb\jul-to-slf4j-1.7.32.jar;C:\Users\young\.gradle\caches\modules-2\files-2.1\org.springframework\spring-jcl\5.3.10\747a2d6ba0d8a74c4f90a8c66c221e3084e864ee\spring-jcl-5.3.10.jar;C:\Users\young\.gradle\caches\modules-2\files-2.1\ch.qos.logback\logback-core\1.2.6\25be1abb32e870ff042e698a799b56587e0dca9a\logback-core-1.2.6.jar;C:\Users\young\.gradle\caches\modules-2\files-2.1\org.slf4j\slf4j-api\1.7.32\cdcff33940d9f2de763bc41ea05a0be5941176c3\slf4j-api-1.7.32.jar;C:\Users\young\.gradle\caches\modules-2\files-2.1\org.apache.logging.log4j\log4j-api\2.14.1\cd8858fbbde69f46bce8db1152c18a43328aae78\log4j-api-2.14.1.jar hello.proxy.ProxyApplication

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v2.5.5)

2022-08-06 14:17:46.283  INFO 19608 --- [           main] hello.proxy.ProxyApplication             : Starting ProxyApplication using Java 11.0.13 on DESKTOP-DH5MQM9 with PID 19608 (C:\Users\young\proxy-start\build\classes\java\main started by young in C:\Users\young\proxy-start)
2022-08-06 14:17:46.287  INFO 19608 --- [           main] hello.proxy.ProxyApplication             : No active profile set, falling back to default profiles: default
2022-08-06 14:17:47.182  INFO 19608 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8081 (http)
2022-08-06 14:17:47.194  INFO 19608 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2022-08-06 14:17:47.194  INFO 19608 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.53]
2022-08-06 14:17:47.284  INFO 19608 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2022-08-06 14:17:47.284  INFO 19608 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 932 ms
2022-08-06 14:17:47.371  INFO 19608 --- [           main] h.p.c.v.ProxyFactoryConfigV2             : ProxyFactory proxy=class hello.proxy.app.v2.OrderRepositoryV2$$EnhancerBySpringCGLIB$$f20a709b, target=class hello.proxy.app.v2.OrderRepositoryV2
2022-08-06 14:17:47.376  INFO 19608 --- [           main] h.p.c.v.ProxyFactoryConfigV2             : ProxyFactory proxy=class hello.proxy.app.v2.OrderServiceV2$$EnhancerBySpringCGLIB$$465a9ebe, target=class hello.proxy.app.v2.OrderServiceV2
2022-08-06 14:17:47.379  WARN 19608 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'orderControllerV2' defined in hello.proxy.config.v3_proxyfactory.ProxyFactoryConfigV2: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [hello.proxy.app.v2.OrderControllerV2]: Factory method 'orderControllerV2' threw exception; nested exception is java.lang.ClassCastException: class com.sun.proxy.$Proxy51 cannot be cast to class hello.proxy.app.v2.OrderControllerV2 (com.sun.proxy.$Proxy51 and hello.proxy.app.v2.OrderControllerV2 are in unnamed module of loader 'app')
2022-08-06 14:17:47.382  INFO 19608 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2022-08-06 14:17:47.396  INFO 19608 --- [           main] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-08-06 14:17:47.421 ERROR 19608 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'orderControllerV2' defined in hello.proxy.config.v3_proxyfactory.ProxyFactoryConfigV2: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [hello.proxy.app.v2.OrderControllerV2]: Factory method 'orderControllerV2' threw exception; nested exception is java.lang.ClassCastException: class com.sun.proxy.$Proxy51 cannot be cast to class hello.proxy.app.v2.OrderControllerV2 (com.sun.proxy.$Proxy51 and hello.proxy.app.v2.OrderControllerV2 are in unnamed module of loader 'app')
	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:658) ~[spring-beans-5.3.10.jar:5.3.10]
	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:638) ~[spring-beans-5.3.10.jar:5.3.10]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352) ~[spring-beans-5.3.10.jar:5.3.10]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195) ~[spring-beans-5.3.10.jar:5.3.10]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) ~[spring-beans-5.3.10.jar:5.3.10]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.10.jar:5.3.10]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.10.jar:5.3.10]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.10.jar:5.3.10]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.10.jar:5.3.10]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.10.jar:5.3.10]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:944) ~[spring-beans-5.3.10.jar:5.3.10]
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) ~[spring-context-5.3.10.jar:5.3.10]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.10.jar:5.3.10]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) ~[spring-boot-2.5.5.jar:2.5.5]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754) ~[spring-boot-2.5.5.jar:2.5.5]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:434) ~[spring-boot-2.5.5.jar:2.5.5]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:338) ~[spring-boot-2.5.5.jar:2.5.5]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1343) ~[spring-boot-2.5.5.jar:2.5.5]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1332) ~[spring-boot-2.5.5.jar:2.5.5]
	at hello.proxy.ProxyApplication.main(ProxyApplication.java:33) ~[main/:na]
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [hello.proxy.app.v2.OrderControllerV2]: Factory method 'orderControllerV2' threw exception; nested exception is java.lang.ClassCastException: class com.sun.proxy.$Proxy51 cannot be cast to class hello.proxy.app.v2.OrderControllerV2 (com.sun.proxy.$Proxy51 and hello.proxy.app.v2.OrderControllerV2 are in unnamed module of loader 'app')
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.3.10.jar:5.3.10]
	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653) ~[spring-beans-5.3.10.jar:5.3.10]
	... 19 common frames omitted
Caused by: java.lang.ClassCastException: class com.sun.proxy.$Proxy51 cannot be cast to class hello.proxy.app.v2.OrderControllerV2 (com.sun.proxy.$Proxy51 and hello.proxy.app.v2.OrderControllerV2 are in unnamed module of loader 'app')
	at hello.proxy.config.v3_proxyfactory.ProxyFactoryConfigV2.orderControllerV2(ProxyFactoryConfigV2.java:26) ~[main/:na]
	at hello.proxy.config.v3_proxyfactory.ProxyFactoryConfigV2$$EnhancerBySpringCGLIB$$9528cf94.CGLIB$orderControllerV2$0(<generated>) ~[main/:na]
	at hello.proxy.config.v3_proxyfactory.ProxyFactoryConfigV2$$EnhancerBySpringCGLIB$$9528cf94$$FastClassBySpringCGLIB$$1b3baf1f.invoke(<generated>) ~[main/:na]
	at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244) ~[spring-core-5.3.10.jar:5.3.10]
	at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331) ~[spring-context-5.3.10.jar:5.3.10]
	at hello.proxy.config.v3_proxyfactory.ProxyFactoryConfigV2$$EnhancerBySpringCGLIB$$9528cf94.orderControllerV2(<generated>) ~[main/:na]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
	at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.3.10.jar:5.3.10]
	... 20 common frames omitted


Process finished with exit code 1

 

 

 
 
 

답변

답변을 기다리고 있는 질문이에요
첫번째 답변을 남겨보세요!
youngyou1324님의 프로필 이미지
youngyou1324

작성한 질문수

질문하기