java.lang.IllegalStateException:模棱两可的映射。无法映射'VausRestController'方法



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

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.

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

<context:annotation-config />
<bean id="VausRestController" class="restController.VausRestController">
    <property name="authenticationManager" ref="authenticationManager" />
</bean>

法典:

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 - 没有帮助。

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

为了修复,我使用了:

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

相关内容

最新更新