我跟随本教程创建一个使用Spring的CRUD应用程序。我希望创建一个存储库,并希望它扩展:
package com.movieseat.repositories;
import java.io.Serializable;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
import com.movieseat.models.Movie;
public interface MovieRepository extends CrudRepository<Movie, Serializable> {}代码是这样说的:
无法解析导入org.springframework.data
我已经删除了.m2文件夹中的存储库文件夹,并进行了重新安装,但仍然没有成功。
我想我在我的pom.xml文件中缺少了一个依赖项,但是我找不到它是哪一个。
//编辑。共享后端文件夹中的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>
<artifactId>backend</artifactId>
<name>backend</name>
<description>The backend project</description>
<parent>
<groupId>com.jdriven.ng2boot</groupId>
<artifactId>parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<properties>
<!-- The main class to start by executing java -jar -->
<start-class>com.movieseat.Application</start-class>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jdriven.ng2boot</groupId>
<artifactId>frontend</artifactId>
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>发布于 2017-09-17 10:14:16
教程中的gradle文件导入以下Spring data JPA依赖项
dependencies {
compile('org.springframework.boot:spring-boot-starter-data-jpa')
...
}它的maven等价于:
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>1.11.7.RELEASE</version>
</dependency>因此,您必须在pom文件中添加上述依赖项。
发布于 2017-09-17 10:04:01
使用以下Maven依赖项
<!-- https://mvnrepository.com/artifact/org.springframework.data/spring-data-commons-core -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons-core</artifactId>
<version>1.0.0.RELEASE</version>
</dependency>您可以根据所使用的Spring版本更改它的版本。用户跟踪链接。https://mvnrepository.com/artifact/org.springframework.data/spring-data-commons-core
https://stackoverflow.com/questions/46262776
复制相似问题