【发布时间】:2015-09-25 06:27:05
【问题描述】:
我正在尝试通过 Spring 实现基于 REST 的 MongoDB 服务,但遇到了一些麻烦。我无法导入某个库。
我班上有这个:
package main;
import java.util.List;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
@RepositoryRestResource(collectionResourceRel = "people", path = "people")
public interface PersonRepository extends MongoRepository<Person, String> {
List<Person> findByLastName(@Param("name") String name);
}
但是import org.springframework.data.rest.core.annotation.RepositoryRestResource;
由于某种原因无法正常工作并给我错误:The import org.springframework.data.rest cannot be resolved
这是我的 maven pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>UserRegistrationServices</groupId>
<artifactId>UserRegistrationServices</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<!-- Inherit defaults from Spring Boot -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.5.RELEASE</version>
</parent>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<!-- Get the dependencies of a web application -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<!-- Spring Boot Maven Support -->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
另外,我直接关注本指南:http://spring.io/guides/gs/accessing-mongodb-data-rest/
如何解决?谢谢
【问题讨论】:
-
你用的是什么IDE?
标签: spring rest spring-mvc spring-boot spring-data