Home > Back-end >  For SpringMVC annotation Ambiguous mapping error
For SpringMVC annotation Ambiguous mapping error

Time:09-18

Build spring + for springmvc + mybatis + maven project, encountered a problem, on the Internet many days off and on, has not been solved, the problem is about, the springmvc annotations, startup has been submitted to the controller error method in the conflict, the specific content is as follows:
Error message:
Severe: Context initialization failed
Org. Springframework. Beans. Factory. BeanCreationException: Error creating bean with the name 'org. Springframework. Web. Servlet. MVC) method. The annotation. The RequestMappingHandlerMapping' : the Invocation of the init method failed; Nested exception is Java. Lang. An IllegalStateException: Ambiguous mapping. Always map 'seckillController method
Public Java. Lang. String org. Buxingshi. Seckill. Controller. SeckillController. Detail (Java. Lang. Long, org. Springframework. UI, the Model)
To {[], the methods=[GET]} : There is already a 'seckillController' bean method
Public Java. Lang. String org. Buxingshi. Seckill. Controller. SeckillController. List (org. Springframework. UI. Model) mapped.
The at org. Springframework. Beans. Factory. Support. AbstractAutowireCapableBeanFactory. InitializeBean (AbstractAutowireCapableBeanFactory. Java: 1578)
The at org. Springframework. Beans. Factory. Support. AbstractAutowireCapableBeanFactory. DoCreateBean (AbstractAutowireCapableBeanFactory. Java: 545)
The at org. Springframework. Beans. Factory. Support. AbstractAutowireCapableBeanFactory. CreateBean (AbstractAutowireCapableBeanFactory. Java: 482)
The at org. Springframework. Beans. Factory. Support. AbstractBeanFactory $1. GetObject (AbstractBeanFactory. Java: 306)
.
Under Caused by: Java. Lang. An IllegalStateException: Ambiguous mapping. Always map 'seckillController method
Public Java. Lang. String org. Buxingshi. Seckill. Controller. SeckillController. Detail (Java. Lang. Long, org. Springframework. UI, the Model)
To {[], the methods=[GET]} : There is already a 'seckillController' bean method
Public Java. Lang. String org. Buxingshi. Seckill. Controller. SeckillController. List (org. Springframework. UI. Model) mapped.
The at org. Springframework. Web. Servlet. Handler. AbstractHandlerMethodMapping $MappingRegistry. AssertUniqueMethodMapping (AbstractHandlerMethodMapping. Java: 567)...

The controller class:
@ Controller
@ RequestMapping (name="/seckill")
Public class SeckillController {
Private static Logger Logger=LoggerFactory. GetLogger (SeckillController. Class);

Private SeckillService SeckillService;

Public SeckillService getSeckillService () {
Return seckillService;
}

The @autowired
Public void setSeckillService (SeckillService SeckillService) {
Enclosing seckillService=seckillService;
}

@ RequestMapping (name="/list", method=RequestMethod. GET)
Public String list (Model Model) {
List List=seckillService. GetSeckillList ();
Model. The addAttribute (" list ", a list);
Return "a list";
}

@ RequestMapping (name="/{seckillId}/detail", method=RequestMethod. GET)
Public String detail (@ PathVariable (" seckillId ") Long seckillId, Model Model) {
If (seckillId==null) {
Return "a list";
}
Seckill Seckill=seckillService. GetById (seckillId);
If (seckill==null) {
The return of "forword:/seckill/list";
}
Model. The addAttribute (" seckill "seckill);
Return "detail";
}
Spring - web. XML configuration:


Pom. The XML depends on the following:


Utf-8 & lt;/project. Build. SourceEncoding>
Utf-8 & lt;/project. Reporting. OutputEncoding>
4.2.5. RELEASE
3.2.8 & lt;/mybatis. Version>
5.1.30 & lt;/mysql - driver. Version>
1.7.18 & lt;/slf4j. Version>
1.1.7 & lt;/logback. Version>
1.0.8 & lt;/protostuff. Version>



Jstl
Jstl
1.2 & lt;/version>



Javax
Javaee - api
7.0 & lt;/version>



Junit
Junit
4.11 & lt;/version>
Test


Commons - lang
  • Related