I have a Spring Component DummyStorageRepositoryand an interface StorageRepositorywritten in Groovy
class DummyStorageRepository implements StorageRepository {...
}
Now in my Application.java application, which is also a Spring boot starter configuration, I have
@Configuration
@ComponentScan
@EnableAutoConfiguration
public class Application implements AsyncConfigurer {
...
@Bean
public StorageRepository storageRepository() {
return new DummyStorageRepository();
}
My Gradle.buid file is plain vanilla.
buildscript {
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath 'org.springframework.boot:spring-boot-gradle-plugin:1.1.8.RELEASE'
classpath 'org.springframework:springloaded:1.2.1.RELEASE'
}
}
apply plugin: 'groovy'
apply plugin: 'spring-boot'
apply plugin: 'project-report'
apply plugin: 'eclipse'
apply plugin: 'idea'
targetCompatibility = 1.8
sourceCompatibility = 1.8
jar {
baseName = 'service'
version = '0.0.1'
}
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
compile 'org.codehaus.groovy:groovy-all:2.3.7:indy'
compile 'org.springframework.boot:spring-boot-starter-actuator:1.1.8.RELEASE'
compile('org.springframework.boot:spring-boot-starter-web:1.1.8.RELEASE')
}
and my file structure
src/main/groovy/com/app/repository/DummyStorageRepository.groovy, StorageRepository.groovy
src/main/java/com/app/Application.java
src/main/resources/...
This is mistake
/app/Application.java:103: error: cannot find symbol
public StorageRepository storageRepository() {
^
symbol: class StorageRepository
location: class Application
If I convert Application.java to Application.groovy and move it to the groovy tree, everything will compile as expected. The same applies if I convert DummyStorageRepository.groovy and StorageRepository.groovy to java and transfer them to the java tree. I am on gradle 2.1 if it has any meaning.
Why can I get a "cannot find character" error when referring to groovy from java?
Update:
Gradle.build, , , .
sourceSets {
main {
groovy {
srcDirs = ['src/main/groovy']
}
java {
srcDirs = ['src/main/java']
}
}
test {
groovy {
srcDirs = ['src/test/groovy','src/test/java']
}
java {
srcDirs = ['src/test/java']
}
}
}