Issue
I have a small Spring Boot test project written in Groovy, built with Gradle. When trying to run with
spring run src/com/eval/EvalMain.groovy src/com/eval/InputObj.groov
I receive
***************************
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.
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. (Plus how did it know the package path java.lang?) Below is my gradle.build, any help would be much appreciated!
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"
}
Solution
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.
constructor com.eval.InputObj required a bean of type 'java.lang.String'
exception is nothing to do with Gradle
as your InputObj
bean object expects a constructor parameter which is a String
parameter which you need to provide (using spring config xml or annotations) to create the bean/object.
Answered By - developer
Answer Checked By - Gilberto Lyons (JavaFixing Admin)