首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >java.lang.IllegalStateException:不明确的映射。无法映射“VausRestController”方法

java.lang.IllegalStateException:不明确的映射。无法映射“VausRestController”方法
EN

Stack Overflow用户
提问于 2017-05-11 00:56:54
回答 1查看 930关注 0票数 0

我正在尝试设置仅支持1个HTTP请求的REST服务器。我收到以下异常:

代码语言:javascript
复制
2017/05/10 16:42:46.036 ERROR:  
 Failed starting server: 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 'VausRestController' method 
 public org.springframework.http.ResponseEntity<com.nds.ch.vge.vaus.restController.VausRestController$ErrorResponse> com.nds.ch.vge.vaus.restController.VausRestController.signature(com.nds.ch.vge.vaus.types.EcdsaSignature)
 to {[/authentication/signature],methods=[PUT]}: There is already 'vausRestController' bean method
 public org.springframework.http.ResponseEntity<com.nds.ch.vge.vaus.restController.VausRestController$ErrorResponse> com.nds.ch.vge.vaus.restController.VausRestController.signature(com.nds.ch.vge.vaus.types.EcdsaSignature) mapped.

应用程序上下文(相关部分):

代码语言:javascript
复制
<context:annotation-config />

<bean id="VausRestController" class="restController.VausRestController">
    <property name="authenticationManager" ref="authenticationManager" />
</bean>

代码:

代码语言:javascript
复制
import javax.annotation.Resource;
import org.springframework.http.ResponseEntity;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;


@Controller
@RestController
public class VausRestController {


    @Resource(name="authenticationManager")
    AuthenticationManager authenticationManager;

    public void setAuthenticationManager(AuthenticationManager authenticationManager) {
        this.authenticationManager = authenticationManager;
    }


    @RequestMapping(value ="/authentication/signature", method = RequestMethod.PUT)
    public ResponseEntity<Object> signature( @RequestBody final EcdsaSignature ecdsaSignature) {

        return ......
    }

请注意,我只有一个@RequestMapping。我也试着改变我的pom.xml的spring版本--没有帮助。

EN

回答 1

Stack Overflow用户

发布于 2017-05-11 00:56:54

失败的原因是,在应用程序上下文'bean‘中,我使用了大写字母id="VausRestController"

为了解决这个问题,我使用:

代码语言:javascript
复制
<bean id="vausRestController" class="restController.VausRestController">
    <property name="authenticationManager" ref="authenticationManager" />
</bean>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43898610

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档