我有一个用 Groovy 编写的小型 Spring Boot 测试项目,使用 Gradle 构建。当尝试使用
运行时spring run src/com/eval/EvalMain.groovy src/com/eval/InputObj.groov
我收到了
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of constructor in com.eval.InputObj required a bean of type 'java.lang.String' that could not be found.
Action:
Consider defining a bean of type 'java.lang.String' in your configuration.
我的印象是 gradle 为我提供了这些东西,而且它应该可以工作,因为 Groovy 是基于 Java 构建的。 (另外它是如何知道包路径java.lang?)下面是我的gradle.build,任何帮助将不胜感激!
buildscript {
ext {
springBootVersion = '1.4.2.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'groovy'
apply plugin: 'org.springframework.boot'
jar {
baseName = 'testJar'
version = '.0.0.2'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
compile('org.springframework.boot:spring-boot-starter')
testCompile('org.springframework.boot:spring-boot-starter-test')
}
springBoot {
mainClass = "com.eval.EvalMain"
}
最佳答案
I was under the impression that gradle included these kinds of things for me, and that it should work since Groovy is built on Java.
构造函数 com.eval.InputObj 需要一个类型为“java.lang.String”的 bean
异常与 Gradle
作为您的 InputObj
无关code> bean 对象需要一个构造函数参数,该参数是一个 String
参数,您需要提供该参数(使用 spring config xml 或注释) 来创建 bean/对象。
关于java - 我不包括 java.lang.String bean?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40670099/