我想使用springboot和hibernate-search-orm,但无法编译项目。
我认为这是因为hibernate版本之间的兼容性问题?
我正在使用Gradle和Intellij Idea。
的build.gradle
buildscript {
ext {
springBootVersion = '1.5.2.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
ext["thymeleaf.version"] = "3.0.2.RELEASE"
ext["thymeleaf-layout-dialect.version"] = "2.0.1"
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
version = '0.0.5-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile('org.springframework.boot:spring-boot-starter-jdbc')
compile('org.springframework.boot:spring-boot-starter-thymeleaf')
compile('org.springframework.boot:spring-boot-starter-web')
compile 'org.springframework.boot:spring-boot-starter-security'
compile ("org.thymeleaf.extras:thymeleaf-extras-springsecurity4:3.0.0.RELEASE")
compile group: 'org.springframework.boot', name: 'spring-boot-starter-logging', version: '1.5.2.RELEASE'
compile group: 'org.thymeleaf.extras', name: 'thymeleaf-extras-springsecurity4', version: '2.1.2.RELEASE'
compile group: 'org.springframework.boot', name: 'spring-boot-autoconfigure', version: '1.5.2.RELEASE'
compile group: 'org.hibernate', name: 'hibernate-search-orm',
version: '5.1.0.Final'
compile("org.springframework.boot:spring-boot-devtools")
compile('mysql:mysql-connector-java')
testCompile('org.springframework.boot:spring-boot-starter-test')
}
bootRun {
addResources = true
}
运行build
时的输出 5:40:30 PM: Executing external task 'build'...
C:\Users\Owner\IdeaProjects\test\src\main\java\com\example\controllers\planController.java:27: warning: sym is internal proprietary API and may be removed in a future release
import static com.sun.org.apache.xalan.internal.xsltc.compiler.sym.error;
^
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 warning
:compileJava
:processResources UP-TO-DATE
:classes
:findMainClass
:jar
:bootRepackage
:assemble
:compileTestJava UP-TO-DATE
:processTestResources UP-TO-DATE
:testClasses UP-TO-DATE
:test
com.example.Demo3ApplicationTests > contextLoads FAILED
java.lang.IllegalStateException
Caused by: org.springframework.beans.factory.BeanCreationException
Caused by: java.lang.AbstractMethodError
1 test completed, 1 failed
:test FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':test'.
> There were failing tests. See the report at: file:///C:/Users/Owner/IdeaProjects/test/build/reports/tests/test/index.html
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 23.392 secs
There were failing tests. See the report at: file:///C:/Users/Owner/IdeaProjects/test/build/reports/tests/test/index.html
5:40:54 PM: External task execution finished 'build'.
我不认为hibernate-search-orm是springboot的一部分,所以我已经明确地将它添加到我的build.gradle文件中。
如果我尝试运行我的项目,则根错误似乎是:
Error handling failed (Error creating bean with name 'delegatingApplicationListener' defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration': Initialization of bean failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'org.springframework.context.annotation.ConfigurationClassPostProcessor.importRegistry' available)
答案 0 :(得分:0)
您需要指定正在使用的依赖项的版本。并且它们应该相互兼容。通过https://mvnrepository.com找到您的spring引导版本并检查Compile Dependencies。与您正在使用的所有其他依赖项一起使用。