Java 无法将Spring数据的依赖项添加到Spring引导中
我试图从开始,并手动包含Spring数据的依赖关系 我的IDE是eclipse,我选择使用Gradle来构建项目Java 无法将Spring数据的依赖项添加到Spring引导中,java,spring,gradle,spring-data,spring-boot,Java,Spring,Gradle,Spring Data,Spring Boot,我试图从开始,并手动包含Spring数据的依赖关系 我的IDE是eclipse,我选择使用Gradle来构建项目 build.gradle和pom.xml都已修改,但eclipse在编译期间仍无法找到Spring数据库(如org.springframework.data.*) 下面是我的build.gradle和pom.xml 有人能告诉我哪里出错了吗?谢谢 Build.gradle buildscript { repositories { maven { url
build.gradle
和pom.xml
都已修改,但eclipse在编译期间仍无法找到Spring数据库(如org.springframework.data.*
)
下面是我的build.gradle
和pom.xml
有人能告诉我哪里出错了吗?谢谢
Build.gradle
buildscript {
repositories {
maven { url "http://repo.spring.io/libs-release" }
mavenLocal()
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.1.1.RELEASE")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'spring-boot'
apply plugin: 'war'
war {
baseName = 'Xiwami'
version = '0.1.0'
}
jar {
baseName = 'Xiwami'
version = '0.1.0'
}
repositories {
mavenLocal()
mavenCentral()
maven { url "http://repo.spring.io/libs-release" }
maven { url "http://m2.neo4j.org" }
}
dependencies {
compile("org.springframework.boot:spring-boot-starter-web")
// spring data : mongodb
compile("org.springframework.data:spring-data-mongodb")
// tag::actuator[]
compile("org.springframework.boot:spring-boot-starter-actuator")
// end::actuator[]
testCompile("junit:junit")
}
task wrapper(type: Wrapper) {
gradleVersion = '1.11'
}
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<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>com.adarp</groupId>
<artifactId>Xiwami</artifactId>
<version>0.1.0</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.1.1.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- tag::actuator[] -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- end::actuator[] -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>
</dependency>
</dependencies>
<properties>
<start-class>hello.Application</start-class>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
4.0.0
com.adarp
西瓦米
0.1.0
org.springframework.boot
spring启动程序父级
1.1.1.发布
org.springframework.boot
SpringBootStarterWeb
org.springframework.boot
弹簧靴起动器执行器
org.springframework.data
spring数据mongodb
你好,申请表
maven编译器插件
2.3.2
org.springframework.boot
springbootmaven插件
无需手动添加spring数据依赖项。弹簧靴也提供了一个开始。加上
compile("org.springframework.boot:spring-boot-starter-data-jpa")
compile("org.springframework.boot:spring-boot-starter-data-mongodb")
到build.gradle
或
org.springframework.boot
和向导
如注释中所述,更改依赖项后,不要忘记在IDE中刷新项目,不需要手动添加spring数据依赖项。弹簧靴也提供了一个开始。加上
compile("org.springframework.boot:spring-boot-starter-data-jpa")
compile("org.springframework.boot:spring-boot-starter-data-mongodb")
到build.gradle
或
org.springframework.boot
和向导
如评论中所述,更改依赖项后,不要忘记在IDE中刷新项目非常感谢!更新build.gradle后,我们必须在包explore-->choose“gradle”-->choose“refresh”中右键单击该项目来刷新该项目,以便在eclipse中清理该项目。@user3556304谢谢!Gradle->刷新是关键,不足以构建。非常感谢!更新build.gradle后,我们必须在包explore-->choose“gradle”-->choose“refresh”中右键单击该项目来刷新该项目,以便在eclipse中清理该项目。@user3556304谢谢!渐变->刷新是关键,不足以构建。