Chr*_*ipp 8 java spring gradle cglib
我使用Spring 3.2与基于Java的配置,并在我的单元测试(JUnit 4.8.1)有一些问题.所以这是一个测试运行者:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes={TestConfig.class})
public class ManualTest
{
@Autowired
...
Run Code Online (Sandbox Code Playgroud)
但是,我收到此错误:
Caused by: java.lang.IllegalStateException: CGLIB is required to process @Configuration classes. Either add CGLIB to the classpath or remove the following @Configuration bean definitions: [testConfig]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.enhanceConfigurationClasses(ConfigurationClassPostProcessor.java:327)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanFactory(ConfigurationClassPostProcessor.java:222)
Run Code Online (Sandbox Code Playgroud)
正如Spring博客所述,Spring 3.2正在内联CGLIB 3.那么为什么我会收到此错误?
我使用Gradle 1.3作为构建管理工具,使用STS作为IDE.当调用gradle eclipse
gradle拉入依赖项两次时:一次作为普通jar,一次作为库:
首先作为普通罐子:
而不是作为图书馆:
在普通jar部分我仍然配置了Spring 3.1,而在库部分则有Spring 3.2.所以我删除了普通罐子,一切正常.
这是我的项目build.gradle
configurations
{
driver
}
dependencies
{
driver 'com.oracle:ojdbc6:11.2.0'
compile "org.springframework:spring-jdbc:$springVersion"
testCompile 'com.oracle:ojdbc6:11.2.0'
testCompile "org.springframework:spring-test:$springVersion"
testCompile "commons-dbcp:commons-dbcp:$dbcpVersion"
testCompile "junit:junit:$junitVersion"
testCompile "org.slf4j:slf4j-log4j12:$slf4jVersion"
}
sourceSets
{
main
{
java
{
srcDirs 'src/main/java', "$buildDir/generated-sources/"
}
}
}
Run Code Online (Sandbox Code Playgroud)
来自主项目的build.gradle
configure(allprojects)
{
ext.dbcpVersion = '1.4'
ext.springVersion = '3.2.0.RELEASE'
ext.junitVersion = '4.8.1'
ext.slf4jVersion = '1.7.2'
}
subprojects
{
// Artifact settings
group = 'xxx'
version = '1.0-SNAPSHOT'
// Standard plugins
apply plugin: 'java'
apply plugin: 'eclipse'
// Repositories
repositories
{
mavenLocal()
maven
{
url "http://repo.springsource.org/release"
}
mavenCentral()
}
// Standard dependencies
dependencies
{
}
}
Run Code Online (Sandbox Code Playgroud)
我删除了所有 Eclipse 项目和设置以及所有 Gradle 临时文件。然后我尝试在 Eclipse 中导入该项目(导入 Gradle 项目..)。这失败了,但有一个例外。然后我删除了 Eclipse 项目中的 Gradle 设置,然后导入就成功了。
所以我不会使用gradle eclipse
1.3版本。
另外,附加源集路径也没有作为源路径进入 Eclipse 项目。
归档时间: |
|
查看次数: |
1762 次 |
最近记录: |