Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled / @RestController μ΄μ© μ ERROR λ°μ
β» ν΄κ²° λ΄μ©μ 맨 λ§μ§λ§μ μμ β»
κ°μ²΄μ§ν₯μ μ¬κ³ μ νλ‘κ·Έλλ° μμ μ λ£λ μ€ μ΄μ κ°μ μλ¬κ° λ°μνμλ€.
κ΅μλμ΄ μ€λͺ ν΄μ£Όμ μ½λλ₯Ό λκ°μ΄ μμ±νλλ°,
λλ§ μ΄λ° μ€λ₯κ° λ°μν κ²μ΄λ€.
νΉν @RestControllerλ₯Ό μ£Όμμ²λ¦¬ ν΄μ νκ³
μ§ννλλ λ°μν μ€λ₯μλ€,,,
( κ·Έ μ μλ μλ§ λλλ°,, μκ·Έλ €,,)
μ€λ₯λ΄μ©μ λ€μκ³Ό κ°λ€.
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-12-02 13:15:47.039 ERROR 28612 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Invocation of init
method failed; nested exception is java.lang.IllegalStateException: Ambiguous mapping. Cannot map 'application' method
com.example.PetAppMidterm.Application#feedDog(Long)
to {PUT [/pets/{petId}/feed]}: There is already 'application' bean method
com.example.PetAppMidterm.Application#feedCat(Long) mapped.
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1804) ~[spring-beans-5.3.12.jar:5.3.12]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) ~[spring-beans-5.3.12.jar:5.3.12]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.12.jar:5.3.12]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.12.jar:5.3.12]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.12.jar:5.3.12]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.12.jar:5.3.12]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.12.jar:5.3.12]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:944) ~[spring-beans-5.3.12.jar:5.3.12]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) ~[spring-context-5.3.12.jar:5.3.12]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.12.jar:5.3.12]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) ~[spring-boot-2.5.6.jar:2.5.6]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754) ~[spring-boot-2.5.6.jar:2.5.6]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:434) ~[spring-boot-2.5.6.jar:2.5.6]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:338) ~[spring-boot-2.5.6.jar:2.5.6]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1343) ~[spring-boot-2.5.6.jar:2.5.6]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1332) ~[spring-boot-2.5.6.jar:2.5.6]
at com.example.PetAppMidterm.Application.main(Application.java:31) ~[classes/:na]
Caused by: java.lang.IllegalStateException: Ambiguous mapping. Cannot map 'application' method
com.example.PetAppMidterm.Application#feedDog(Long)
to {PUT [/pets/{petId}/feed]}: There is already 'application' bean method
com.example.PetAppMidterm.Application#feedCat(Long) mapped.
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping$MappingRegistry.validateMethodMapping(AbstractHandlerMethodMapping.java:669) ~[spring-webmvc-5.3.12.jar:5.3.12]
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping$MappingRegistry.register(AbstractHandlerMethodMapping.java:635) ~[spring-webmvc-5.3.12.jar:5.3.12]
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.registerHandlerMethod(AbstractHandlerMethodMapping.java:332) ~[spring-webmvc-5.3.12.jar:5.3.12]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.registerHandlerMethod(RequestMappingHandlerMapping.java:395) ~[spring-webmvc-5.3.12.jar:5.3.12]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.registerHandlerMethod(RequestMappingHandlerMapping.java:76) ~[spring-webmvc-5.3.12.jar:5.3.12]
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.lambda$detectHandlerMethods$2(AbstractHandlerMethodMapping.java:299) ~[spring-webmvc-5.3.12.jar:5.3.12]
at java.base/java.util.LinkedHashMap.forEach(LinkedHashMap.java:723) ~[na:na]
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.detectHandlerMethods(AbstractHandlerMethodMapping.java:297) ~[spring-webmvc-5.3.12.jar:5.3.12]
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.processCandidateBean(AbstractHandlerMethodMapping.java:266) ~[spring-webmvc-5.3.12.jar:5.3.12]
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.initHandlerMethods(AbstractHandlerMethodMapping.java:225) ~[spring-webmvc-5.3.12.jar:5.3.12]
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.afterPropertiesSet(AbstractHandlerMethodMapping.java:213) ~[spring-webmvc-5.3.12.jar:5.3.12]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.afterPropertiesSet(RequestMappingHandlerMapping.java:206) ~[spring-webmvc-5.3.12.jar:5.3.12]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863) ~[spring-beans-5.3.12.jar:5.3.12]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.j800) ~[spring-beans-5.3.12.jar:5.3.12]
... 16 common frames omitted
Cannot map 'application' method
com.example.PetAppMidterm.Application#feedDog(Long)
to {PUT [/pets/{petId}/feed]}: There is already 'application' bean method
μλ¬λ¬Έμ μ΄ν΄λ³΄λ©΄,
μ΄μ κ°μ λ΄μ©μ΄ μλ€.
μ½λλ₯Ό μ΄ν΄λ³΄λ,
λ°λ³΄κ°μ΄ κ°μ pathλ₯Ό μμ±ν κ²μ΄ μλκ² λκ°.
//path λΆλΆμ΄ μλͺ»λμ΄ μλ κ²μ,,, μ무리 μκ°ν΄λ μ κ°μ κ²μΌλ‘ ν μκ°μ νμ§ λ°λ³΄μ
@RequestMapping(method = RequestMethod.PUT, path="cats/{petId}/feed")
public String feedCat(@PathVariable(value = "petId") Long petId){
return feed(petId);
}
@RequestMapping(method = RequestMethod.PUT, path="dogs/{petId}/feed")
public String feedDog(@PathVariable(value = "petId") Long petId){
return feed(petId);
}
λ€μ λ³κ²½ν΄μ£Όλ μ λλ κ²μ νμΈ ν μ μλ€.
μμ§κΉμ§ μλ¬λ¬Έμ 보λ κ²μ΄ μ΄λ ΅κ³ ,
ꡬκΈλ§μ κ³μνκ³ μμ§λ§,
μμ΄μ μ½λ©κ³΅λΆλ₯Ό μ΄μ¬νν΄μ
μλ¬λ¬Έμ μ μ‘μ μ μλλ‘ λ Έλ ₯ν΄μΌκ² λ€.