2016-05-17 19 views
2

我並沒有做什麼特別的到現在爲止,但得到這個惱人的例外:爲什麼我在Spring Boot Rest Data Application中爲HTTP路徑映射了模糊的處理程序方法?

java.lang.IllegalStateException:映射爲HTTP路徑「http://localhost:8080/directoryWatches」不明確的處理方法:{公共org.springframework.http.ResponseEntity組織。 springframework.data.rest.webmvc.RepositoryEntityController.headCollectionResource(org.springframework.data.rest.webmvc.RootResourceInformation,org.springframework.data.rest.webmvc.support.DefaultedPageable)throws org.springframework.web.HttpRequestMethodNotSupportedException,public org。 springframework.hateoas.Resources org.springframework.data.rest.webmvc.RepositoryEntityController.getCollectionResource(org.springframework.data.rest.webmvc.RootResourceInformation,org.springframework.data.rest.webmvc.support.DefaultedPa geable,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中號編制方法: enter image description here

片斷我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> 

有沒有人伸出援助的想法?

謝謝 基督教

+0

請添加您的POM的相關片段或聲明使用的工件的版本。 – Thomas

+0

您好托馬斯。增加了pom代表。 – Chrisposure

+0

@Chrisposure你可以添加你的控制器代碼 ? – cralfaro

回答

0

這個可疑看起來像Spring框架4.3 RC1的迴歸,我已經報here。問題已經解決,即將推出的Spring Boot 1.4 M3將包含固定版本。

發佈引導應該在幾天內可用。在此之前,您可以手動升級到Spring Framework 4.3 RC2。

+0

謝謝奧利弗。回到Spring Boot 1.3.5做了破解... – Chrisposure

+0

@Chrisposure - 1.4 M3在那裏修復了問題。 –

+0

謝謝奧利弗! – Chrisposure

相關問題