繁体   English   中英

为什么我的Spring Boot Rest Data Application中为HTTP路径映射了模糊的处理程序方法?

[英]Why do I have ambiguous handler methods mapped for HTTP path in my Spring Boot Rest Data Application?

到目前为止,我还没有做任何特别的事情,但是有一个令人讨厌的异常:

java.lang.IllegalStateException:为HTTP路径' http:// localhost:8080 / directoryWatches映射的模糊处理程序方法:{public org.springframework.http.ResponseEntity org.springframework.data.rest.webmvc.RepositoryEntityController.headCollectionResource(org。 springframework.data.rest.webmvc.RootResourceInformation,org.springframework.data.rest.webmvc.support.DefaultedPageable)抛出org.springframework.web.HttpRequestMethodNotSupportedException,公共org.springframework.hateoas.Resources org.springframework.data.rest.webmvc .RepositoryEntityController.getCollectionResource(org.springframework.data.rest.webmvc.RootResourceInformation,org.springframework.data.rest.webmvc.support.DefaultedPageable,org.springframework.data.domain.Sort,org.springframework.data.rest.webmvc .PersistentEntityResourceAssembler)引发org.springframework.data.rest.webmvc.ResourceNotFoundException,org.springframework.web.HttpRequestMethodNotSupportedException}

这是我的实体:

@Entity
public class DirectoryWatch {

@Id
@GeneratedValue
private long id;

@Column(unique = true)
private String name;
//setters, getters and default constructor...
}

而我的DirectoryWatchRepository:

@RepositoryRestResource
public interface DirectoryWatchRepository extends PagingAndSortingRepository<DirectoryWatch, Long> {
}

当我打开HAL浏览器并尝试打开NON-GET HTTP方法时,会发生异常: 在此处输入图片说明

我的pom文件的片段:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.4.0.M2</version>
    <relativePath /> <!-- lookup parent from repository -->
</parent>

Dependencies:
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-actuator-docs</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-rest</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-rest-hal-browser</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-hateoas</artifactId>
    </dependency>
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-mail</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-remote-shell</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.restdocs</groupId>
        <artifactId>spring-restdocs-mockmvc</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.scala-lang</groupId>
        <artifactId>scala-library</artifactId>
        <version>2.11.0</version>
    </dependency>
</dependencies>

有没有人有帮助的想法?

谢谢克里斯蒂安

这看起来像是我在这里报告的Spring Framework 4.3 RC1中的回归。 该问题已得到解决,即将发布的Spring Boot 1.4 M3将包含已修复的版本。

发行版Boot应该会在几天之内可用。 在此之前,您可以手动升级到Spring Framework 4.3 RC2。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM