Errors for repository and service:
Error creating bean with name 'rimeService' defined in file [...]: Unsatisfied dependency expressed through constructor parameter 0;
nested exception is java.lang.NoClassDefFoundError: kotlin/reflect/full/KClasses
Error creating bean with name 'rimeRepository': Invocation of init method failed;
nested exception is java.lang.NoClassDefFoundError: kotlin/reflect/full/KClasses
RimeService:
@Service
class RimeService(private val repository: RimeRepository) {
fun findRimes(character: String) = repository.findByCharactersContains(character)
}
RimeRepository:
@Repository
interface RimeRepository: JpaRepository<Rime, Int> {
fun findByCharactersContains(character: String): List<Rime>
}
Controller:
@Controller
@RequestMapping("/rimes")
class RimeController(private val service: RimeService) {
@GetMapping("/{character}")
fun getByCharacter(@PathVariable character: String) = service.findRimes(character)
}
dependencies:
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
// implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-web'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
runtimeOnly 'mysql:mysql-connector-java'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
testImplementation 'org.springframework.security:spring-security-test'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
}
In addition, the class and methods in controller is grayed out in Intelij, which means those are never used.
Please let me know if there's anything wrong with my configuration. Thank you.