Skip to content
Advertisement

Failed to load a service: io.micronaut.context.exceptions.BeanContextException: | Micronaut

I have just created a file named TransactionsRepository.java. I am not calling this class anywhere as of now

TransactionsRepository.java

package com.example.Transactions;

import io.micronaut.data.annotation.Repository;

// @Repository
public interface TransactionsRepository {
}

Whenever I run ./gradlew run, it runs perfectly, but the moment I uncomment this line, it throws an error

@Repository

ERROR

Exception in thread “main” java.lang.RuntimeException: Failed to load a service: io.micronaut.context.exceptions.BeanContextException: Unexpected error loading be an definition [com.example.$Transactions.TransactionsRepository$Intercepted$Definition]: failed to access class com.example.Transactions.TransactionsRepository$In tercepted from class com.example.$Transactions.TransactionsRepository$Intercepted$Definition$Reference (com.example.Transactions.TransactionsRepository$Intercepte d and com.example.$Transactions.TransactionsRepository$Intercepted$Definition$Reference are in unnamed module of loader ‘app’)

I even tried doing this but still does not work

@Repository
public interface TransactionsRepository extends  CrudRepository<Transaction, Long>{
}

I have also included below line in my gradle file

annotationProcessor("io.micronaut.data:micronaut-data-hibernate-jpa")


I am very new to micronaut. Its been hours I am trying this. I dont know whats wrong in this code. Please help me if I am missing something.

Advertisement

Answer

It’s probably the package name – package sub-names should not start with uppercase letters. Change com.example.Transactions to com.example.transactions (and rename the directory from Transactions to transactions.

Advertisement