Spring Boot Неоднозначное отображение. Невозможно сопоставить методJAVA

Программисты JAVA общаются здесь
Ответить Пред. темаСлед. тема
Anonymous
 Spring Boot Неоднозначное отображение. Невозможно сопоставить метод

Сообщение Anonymous »

В моем приложении Spring Boot есть 2 контроллера REST с простыми операциями CRUD.

Контроллер REST, сопоставленный с «/json/currency»

Код: Выделить всё

package ua.alekstar.moneysaver.rest;

import org.springframework.web.bind.annotation.*;
import ua.alekstar.moneysaver.rest.currency.Currencies;
import ua.alekstar.moneysaver.rest.currency.Currency;
import ua.alekstar.moneysaver.service.CurrencyService;

import java.util.Collections;

@RestController("/json/currency")
public class CurrencyJsonRestController {

private final CurrencyService currencyService;

public CurrencyJsonRestController(CurrencyService currencyService) {
this.currencyService = currencyService;
}

@GetMapping
@ResponseBody
public Currencies get(@RequestParam(required = false) Long id) {
if (id == null) {
return readAll();
}
return read(id);
}

private Currencies read(Long id) {
return new Currencies(Collections.singletonList(currencyService.read(id)));
}

private Currencies readAll() {
return new Currencies(currencyService.readAll());
}

@PostMapping
public void post(@RequestBody Currency currency) {
currencyService.create(currency.toEntity());
}

@PutMapping
public void put(@RequestBody Currency currency) {
currencyService.update(currency.toEntity());
}

@DeleteMapping
public void delete(@RequestParam Long id) {
currencyService.delete(id);
}
}
и контроллер REST, сопоставленный с «/json/account»

Код: Выделить всё

package ua.alekstar.moneysaver.rest;

import org.springframework.web.bind.annotation.*;
import ua.alekstar.moneysaver.dao.entities.Currency;
import ua.alekstar.moneysaver.rest.account.Account;
import ua.alekstar.moneysaver.rest.account.Accounts;
import ua.alekstar.moneysaver.service.AccountService;
import ua.alekstar.moneysaver.service.CurrencyService;

import java.util.Collections;

@RestController("/json/account")
public class AccountJsonRestController {

private final AccountService accountService;
private final CurrencyService currencyService;

public AccountJsonRestController(AccountService accountService, CurrencyService currencyService) {
this.accountService = accountService;
this.currencyService = currencyService;
}

@GetMapping
@ResponseBody
public Accounts get(@RequestParam(required = false) Long id) {
if (id == null) {
return readAll();
}
return read(id);
}

private Accounts read(Long id) {
return new Accounts(Collections.singletonList(accountService.read(id)));
}

private Accounts readAll() {
return new Accounts(accountService.readAll());
}

@PostMapping
public void post(@RequestBody Account account) {
accountService.create(toEntity(account));
}

private ua.alekstar.moneysaver.dao.entities.Account toEntity(Account account) {
final Currency currency = currencyService.readByIsoCode(account.getCurrency());
return new ua.alekstar.moneysaver.dao.entities.Account(account.getId(), account.getName(), currency);
}

@PutMapping
public void put(@RequestBody Account account) {
accountService.update(toEntity(account));
}

@DeleteMapping
public void delete(@RequestParam Long id) {
accountService.delete(id);
}

}
При запуске приложения у меня возникает исключение, и я не понимаю, п о ч е м у э т о п р о и с х о д и т . < / p > < b r / > < b r / > < c o d e > / u s r / l i b / j v m / j a v a - 8 - o r a c l e / b i n / j a v a - X X : T i e r e d S t o p A t L e v e l = 1 - n o v e r i f y - D s p r i n g . o u t p u t . a n s i . e n a b l e d = a l w a y s - j a v a a g e n t : / h o m e / s a s h a / A p p l i c a t i o n s / i d e a - I U - 1 7 1 . 3 7 8 0 . 1 0 7 / l i b / i d e a _ r t . j a r = 3 2 8 2 0 : / h o m e / s a s h a / A p p l i c a t i o n s / i d e a - I U - 1 7 1 . 3 7 8 0 . 1 0 7 / b i n - D f i l e . e n c o d i n g = U T F - 8 - c l a s s p a t h / u s r / l i b / j v m / j a v a - 8 - o r a c l e / j r e / l i b / c h a r s e t s . j a r : / u s r / l i b / j v m / j a v a - 8 - o r a c l e / j r e / l i b / d e p l o y . j a r : / u s r / l i b / j v m / j a v a - 8 - o r a c l e / j r e / l i b / e x t / c l d r d a t a . j a r : / u s r / l i b / j v m / j a v a - 8 - o r a c l e / j r e / l i b / e x t / d n s n s . j a r : / u s r / l i b / j v m / j a v a - 8 - o r a c l e / j r e / l i b / e x t / j a c c e s s . j a r : / u s r / l i b / j v m / j a v a - 8 - o r a c l e / j r e / l i b / e x t / j f x r t . j a r : / u s r / l i b / j v m / j a v a - 8 - o r a c l e / j r e / l i b / e x t / l o c a l e d a t a . j a r : / u s r / l i b / j v m / j a v a - 8 - o r a c l e / j r e / l i b / e x t / n a s h o r n . j a r : / u s r / l i b / j v m / j a v a - 8 - o r a c l e / j r e / l i b / e x t / s u n e c . j a r : / u s r / l i b / j v m / j a v a - 8 - o r a c l e / j r e / l i b / e x t / s u n j c e _ p r o v i d e r . j a r : / u s r / l i b / j v m / j a v a - 8 - o r a c l e / j r e / l i b / e x t / s u n p k c s 1 1 . j a r : / u s r / l i b / j v m / j a v a - 8 - o r a c l e / j r e / l i b / e x t / z i p f s . j a r : / u s r / l i b / j v m / j a v a - 8 - o r a c l e / j r e / l i b / j a v a w s . j a r : / u s r / l i b / j v m / j a v a - 8 - o r a c l e / j r e / l i b / j c e . j a r : / u s r / l i b / j v m / j a v a - 8 - o r a c l e / j r e / l i b / j f r . j a r : / u s r / l i b / j v m / j a v a - 8 - o r a c l e / j r e / l i b / j f x s w t . j a r : / u s r / l i b / j v m / j a v a - 8 - o r a c l e / j r e / l i b / j s s e . j a r : / u s r / l i b / j v m / j a v a - 8 - o r a c l e / j r e / l i b / m a n a g e m e n t - a g e n t . j a r : / u s r / l i b / j v m / j a v a - 8 - o r a c l e / j r e / l i b / p l u g i n . j a r : / u s r / l i b / j v m / j a v a - 8 - o r a c l e / j r e / l i b / r e s o u r c e s . j a r : / u s r / l i b / j v m / j a v a - 8 - o r a c l e / j r e / l i b / r t . j a r : / h o m e / s a s h a / D o c u m e n t s / d e v e l o p m e n t / m o n e y s a v e r / t a r g e t / c l a s s e s : / h o m e / s a s h a / . m 2 / r e p o s i t o r y / o r g / s p r i n g f r a m e w o r k / b o o t / s p r i n g - b o o t - s t a r t e r - d a t a - j p a / 1 . 5 . 3 . R E L E A S E / s p r i n g - b o o t - s t a r t e r - d a t a - j p a - 1 . 5 . 3 . R E L E A S E . j a r : / h o m e / s a s h a / . m 2 / r e p o s i t o r y / o r g / s p r i n g f r a m e w o r k / b o o t / s p r i n g - b o o t - s t a r t e r / 1 . 5 . 3 . R E L E A S E / s p r i n g - b o o t - s t a r t e r - 1 . 5 . 3 . R E L E A S E . j a r : / h o m e / s a s h a / . m 2 / r e p o s i t o r y / o r g / s p r i n g f r a m e w o r k / b o o t / s p r i n g - b o o t / 1 . 5 . 3 . R E L E A S E / s p r i n g - b o o t - 1 . 5 . 3 . R E L E A S E . j a r : / h o m e / s a s h a / . m 2 / r e p o s i t o r y / o r g / s p r i n g f r a m e w o r k / b o o t / s p r i n g - b o o t - a u t o c o n f i g u r e / 1 . 5 . 3 . R E L E A S E / s p r i n g - b o o t - a u t o c o n f i g u r e - 1 . 5 . 3 . R E L E A S E . j a r : / h o m e / s a s h a / . m 2 / r e p o s i t o r y / o r g / s p r i n g f r a m e w o r k / b o o t / s p r i n g - b o o t - s t a r t e r - l o g g i n g / 1 . 5 . 3 . R E L E A S E / s p r i n g - b o o t - s t a r t e r - l o g g i n g - 1 . 5 . 3 . R E L E A S E . j a r : / h o m e / s a s h a / . m 2 / r e p o s i t o r y / c h / q o s / l o g b a c k / l o g b a c k - c l a s s i c / 1 . 1 . 1 1 / l o g b a c k - c l a s s i c - 1 . 1 . 1 1 . j a r : / h o m e / s a s h a / . m 2 / r e p o s i t o r y / c h / q o s / l o g b a c k / l o g b a c k - c o r e / 1 . 1 . 1 1 / l o g b a c k - c o r e - 1 . 1 . 1 1 . j a r : / h o m e / s a s h a / . m 2 / r e p o s i t o r y / o r g / s l f 4 j / j u l - t o - s l f 4 j / 1 . 7 . 2 5 / j u l - t o - s l f 4 j - 1 . 7 . 2 5 . j a r : / h o m e / s a s h a / . m 2 / r e p o s i t o r y / o r g / s l f 4 j / l o g 4 j - o v e r - s l f 4 j / 1 . 7 . 2 5 / l o g 4 j - o v e r - s l f 4 j - 1 . 7 . 2 5 . j a r : / h o m e / s a s h a / . m 2 / r e p o s i t o r y / o r g / y a m l / s n a k e y a m l / 1 . 1 7 / s n a k e y a m l - 1 . 1 7 . j a r : / h o m e / s a s h a / . m 2 / r e p o s i t o r y / o r g / s p r i n g f r a m e w o r k / b o o t / s p r i n g - b o o t - s t a r t e r - a o p / 1 . 5 . 3 . R E L E A S E / s p r i n g - b o ot-starter-aop-1.5.3.RELEASE.jar:/home/sasha/.m2/repository/org/springframework/spring-aop/4.3.8.RELEASE/spring-aop-4.3.8.RELEASE.jar:/home/sasha/.m2/repository/org/aspectj/aspectjweaver/1.8.10/aspectjweaver-1.8.10.jar:/home/sasha/.m2/repository/org/springframework/boot/spring-boot-starter-jdbc/1.5.3.RELEASE/spring-boot-starter-jdbc-1.5.3.RELEASE.jar:/home/sasha/.m2/repository/org/apache/tomcat/tomcat-jdbc/8.5.14/tomcat-jdbc-8.5.14.jar:/home/sasha/.m2/repository/org/apache/tomcat/tomcat-juli/8.5.14/tomcat-juli-8.5.14.jar:/home/sasha/.m2/repository/org/springframework/spring-jdbc/4.3.8.RELEASE/spring-jdbc-4.3.8.RELEASE.jar:/home/sasha/.m2/repository/javax/transaction/javax.transaction-api/1.2/javax.transaction-api-1.2.jar:/home/sasha/.m2/repository/org/springframework/data/spring-data-jpa/1.11.3.RELEASE/spring-data-jpa-1.11.3.RELEASE.jar:/home/sasha/.m2/repository/org/springframework/data/spring-data-commons/1.13.3.RELEASE/spring-data-commons-1.13.3.RELEASE.jar:/home/sasha/.m2/repository/org/springframework/spring-orm/4.3.8.RELEASE/spring-orm-4.3.8.RELEASE.jar:/home/sasha/.m2/repository/org/springframework/spring-context/4.3.8.RELEASE/spring-context-4.3.8.RELEASE.jar:/home/sasha/.m2/repository/org/springframework/spring-tx/4.3.8.RELEASE/spring-tx-4.3.8.RELEASE.jar:/home/sasha/.m2/repository/org/springframework/spring-beans/4.3.8.RELEASE/spring-beans-4.3.8.RELEASE.jar:/home/sasha/.m2/repository/org/slf4j/slf4j-api/1.7.25/slf4j-api-1.7.25.jar:/home/sasha/.m2/repository/org/slf4j/jcl-over-slf4j/1.7.25/jcl-over-slf4j-1.7.25.jar:/home/sasha/.m2/repository/org/springframework/spring-aspects/4.3.8.RELEASE/spring-aspects-4.3.8.RELEASE.jar:/home/sasha/.m2/repository/org/springframework/boot/spring-boot-starter-web/1.5.3.RELEASE/spring-boot-starter-web-1.5.3.RELEASE.jar:/home/sasha/.m2/repository/org/springframework/boot/spring-boot-starter-tomcat/1.5.3.RELEASE/spring-boot-starter-tomcat-1.5.3.RELEASE.jar:/home/sasha/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/8.5.14/tomcat-embed-core-8.5.14.jar:/home/sasha/.m2/repository/org/apache/tomcat/embed/tomcat-embed-el/8.5.14/tomcat-embed-el-8.5.14.jar:/home/sasha/.m2/repository/org/apache/tomcat/embed/tomcat-embed-websocket/8.5.14/tomcat-embed-websocket-8.5.14.jar:/home/sasha/.m2/repository/org/hibernate/hibernate-validator/5.3.5.Final/hibernate-validator-5.3.5.Final.jar:/home/sasha/.m2/repository/javax/validation/validation-api/1.1.0.Final/validation-api-1.1.0.Final.jar:/home/sasha/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.8.8/jackson-databind-2.8.8.jar:/home/sasha/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.8.0/jackson-annotations-2.8.0.jar:/home/sasha/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.8.8/jackson-core-2.8.8.jar:/home/sasha/.m2/repository/org/springframework/spring-web/4.3.8.RELEASE/spring-web-4.3.8.RELEASE.jar:/home/sasha/.m2/repository/org/springframework/spring-webmvc/4.3.8.RELEASE/spring-webmvc-4.3.8.RELEASE.jar:/home/sasha/.m2/repository/org/springframework/spring-expression/4.3.8.RELEASE/spring-expression-4.3.8.RELEASE.jar:/home/sasha/.m2/repository/org/springframework/spring-core/4.3.8.RELEASE/spring-core-4.3.8.RELEASE.jar:/home/sasha/.m2/repository/org/hibernate/javax/persistence/hibernate-jpa-2.0-api/1.0.1.Final/hibernate-jpa-2.0-api-1.0.1.Final.jar:/home/sasha/.m2/repository/org/hibernate/hibernate-core/5.2.10.Final/hibernate-core-5.2.10.Final.jar:/home/sasha/.m2/repository/org/jboss/logging/jboss-logging/3.3.1.Final/jboss-logging-3.3.1.Final.jar:/home/sasha/.m2/repository/org/hibernate/javax/persistence/hibernate-jpa-2.1-api/1.0.0.Final/hibernate-jpa-2.1-api-1.0.0.Final.jar:/home/sasha/.m2/repository/org/javassist/javassist/3.21.0-GA/javassist-3.21.0-GA.jar:/home/sasha/.m2/repository/antlr/antlr/2.7.7/antlr-2.7.7.jar:/home/sasha/.m2/repository/org/jboss/spec/javax/transaction/jboss-transaction-api_1.2_spec/1.0.1.Final/jboss-transaction-api_1.2_spec-1.0.1.Final.jar:/home/sasha/.m2/repository/org/jboss/jandex/2.0.3.Final/jandex-2.0.3.Final.jar:/home/sasha/.m2/repository/com/fasterxml/classmate/1.3.3/classmate-1.3.3.jar:/home/sasha/.m2/repository/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar:/home/sasha/.m2/repository/org/hibernate/common/hibernate-commons-annotations/5.0.1.Final/hibernate-commons-annotations-5.0.1.Final.jar:/home/sasha/.m2/repository/org/hibernate/hibernate-entitymanager/5.2.10.Final/hibernate-entitymanager-5.2.10.Final.jar:/home/sasha/.m2/repository/net/bytebuddy/byte-buddy/1.6.6/byte-buddy-1.6.6.jar:/home/sasha/.m2/repository/org/hibernate/hibernate-ehcache/5.2.10.Final/hibernate-ehcache-5.2.10.Final.jar:/home/sasha/.m2/repository/net/sf/ehcache/ehcache/2.10.4/ehcache-2.10.4.jar:/home/sasha/.m2/repository/com/mchange/c3p0/0.9.5.2/c3p0-0.9.5.2.jar:/home/sasha/.m2/repository/com/mchange/mchange-commons-java/0.2.11/mchange-commons-java-0.2.11.jar:/home/sasha/.m2/repository/org/postgresql/postgresql/42.0.0/postgresql-42.0.0.jar ua.alekstar.moneysaver.MoneysaverApplication

. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.5.3.RELEASE)

2017-05-13 21:15:20.109 INFO 9745 --- [ main] u.a.moneysaver.MoneysaverApplication : Starting MoneysaverApplication on sasha-pc with PID 9745 (/home/sasha/Documents/development/moneysaver/target/classes started by sasha in /home/sasha/Documents/development/moneysaver)
2017-05-13 21:15:20.112 INFO 9745 --- [ main] u.a.moneysaver.MoneysaverApplication : No active profile set, falling back to default profiles: default
2017-05-13 21:15:20.165 INFO 9745 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@319b92f3: startup date [Sat May 13 21:15:20 EEST 2017]; root of context hierarchy
2017-05-13 21:15:22.043 INFO 9745 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2017-05-13 21:15:22.053 INFO 9745 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat
2017-05-13 21:15:22.054 INFO 9745 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.14
2017-05-13 21:15:22.147 INFO 9745 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2017-05-13 21:15:22.147 INFO 9745 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1985 ms
2017-05-13 21:15:22.259 INFO 9745 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2017-05-13 21:15:22.262 INFO 9745 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2017-05-13 21:15:22.263 INFO 9745 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2017-05-13 21:15:22.263 INFO 9745 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2017-05-13 21:15:22.263 INFO 9745 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2017-05-13 21:15:22.311 INFO 9745 --- [g-Init-Reporter] com.mchange.v2.log.MLog : MLog clients using slf4j logging.
2017-05-13 21:15:22.394 INFO 9745 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2017-05-13 21:15:22.404 INFO 9745 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2017-05-13 21:15:22.468 INFO 9745 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.2.10.Final}
2017-05-13 21:15:22.470 INFO 9745 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2017-05-13 21:15:22.503 INFO 9745 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
2017-05-13 21:15:22.628 INFO 9745 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQL94Dialect
2017-05-13 21:15:22.737 INFO 9745 --- [ main] o.h.e.j.e.i.LobCreatorBuilderImpl : HHH000424: Disabling contextual LOB creation as createClob() method threw error : java.lang.reflect.InvocationTargetException
2017-05-13 21:15:22.739 INFO 9745 --- [ main] org.hibernate.type.BasicTypeRegistry : HHH000270: Type registration [java.util.UUID] overrides previous : org.hibernate.type.UUIDBinaryType@1e008f36
2017-05-13 21:15:23.195 INFO 9745 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2017-05-13 21:15:23.645 INFO 9745 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@319b92f3: startup date [Sat May 13 21:15:20 EEST 2017]; root of context hierarchy
2017-05-13 21:15:23.697 INFO 9745 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[],methods=[POST]}" onto public void ua.alekstar.moneysaver.rest.AccountJsonRestController.post(ua.alekstar.moneysaver.rest.account.Account)
2017-05-13 21:15:23.698 INFO 9745 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[],methods=[GET]}" onto public ua.alekstar.moneysaver.rest.account.Accounts ua.alekstar.moneysaver.rest.AccountJsonRestController.get(java.lang.Long)
2017-05-13 21:15:23.698 INFO 9745 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[],methods=[PUT]}" onto public void ua.alekstar.moneysaver.rest.AccountJsonRestController.put(ua.alekstar.moneysaver.rest.account.Account)
2017-05-13 21:15:23.698 INFO 9745 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[],methods=[DELETE]}" onto public void ua.alekstar.moneysaver.rest.AccountJsonRestController.delete(java.lang.Long)
2017-05-13 21:15:23.700 WARN 9745 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: Ambiguous mapping. Cannot map '/json/currency' method
public void ua.alekstar.moneysaver.rest.CurrencyJsonRestController.post(ua.alekstar.moneysaver.rest.currency.Currency)
to {[],methods=[POST]}: There is already '/json/account' bean method
public void ua.alekstar.moneysaver.rest.AccountJsonRestController.post(ua.alekstar.moneysaver.rest.account.Account) mapped.
2017-05-13 21:15:23.701 INFO 9745 --- [ main] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2017-05-13 21:15:23.703 INFO 9745 --- [ main] o.apache.catalina.core.StandardService : Stopping service Tomcat
2017-05-13 21:15:23.716 INFO 9745 --- [ main] utoConfigurationReportLoggingInitializer :

Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2017-05-13 21:15:23.722 ERROR 9745 --- [ main] o.s.boot.SpringApplication : Application startup failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: Ambiguous mapping. Cannot map '/json/currency' method
public void ua.alekstar.moneysaver.rest.CurrencyJsonRestController.post(ua.alekstar.moneysaver.rest.currency.Currency)
to {[],methods=[POST]}: There is already '/json/account' bean method
public void ua.alekstar.moneysaver.rest.AccountJsonRestController.post(ua.alekstar.moneysaver.rest.account.Account) mapped.
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866) ~[spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542) ~[spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:737) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:370) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at ua.alekstar.moneysaver.MoneysaverApplication.main(MoneysaverApplication.java:10) [classes/:na]
Caused by: java.lang.IllegalStateException: Ambiguous mapping. Cannot map '/json/currency' method
public void ua.alekstar.moneysaver.rest.CurrencyJsonRestController.post(ua.alekstar.moneysaver.rest.currency.Currency)
to {[],methods=[POST]}: There is already '/json/account' bean method
public void ua.alekstar.moneysaver.rest.AccountJsonRestController.post(ua.alekstar.moneysaver.rest.account.Account) mapped.
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping$MappingRegistry.assertUniqueMethodMapping(AbstractHandlerMethodMapping.java:576) ~[spring-webmvc-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping$MappingRegistry.register(AbstractHandlerMethodMapping.java:540) ~[spring-webmvc-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.registerHandlerMethod(AbstractHandlerMethodMapping.java:264) ~[spring-webmvc-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.detectHandlerMethods(AbstractHandlerMethodMapping.java:250) ~[spring-webmvc-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.initHandlerMethods(AbstractHandlerMethodMapping.java:214) ~[spring-webmvc-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.afterPropertiesSet(AbstractHandlerMethodMapping.java:184) ~[spring-webmvc-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.afterPropertiesSet(RequestMappingHandlerMapping.java:127) ~[spring-webmvc-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]
... 16 common frames omitted

Process finished with exit code 1


После удаления одного из контроллеров REST приложение запускается успешно. Что мне следует сделать, чтобы решить эту проблему?

Подробнее здесь: https://stackoverflow.com/questions/439 ... map-method
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «JAVA»