I'm trying to load into my micronaut CLI application (cli.jar) some classes from an external jar, annotated with @Singleton in hope that they will be injected in the application. That doesn't happen, even though the classes actually packaged (shadowed) in the cli.jar. I tried to see with java -verbose, whether the classes in the class loader and they are not.
Can it work with micronaut?
Is the external jar build correctly with the annotations processors configured correctly?
no, it's just a jar with compiled classes which are annotated with @Singleton.
But I got your point. Will try.
yes that works like a charm. I just added these deps:
plugins {
id 'java'
id "io.spring.dependency-management" version "1.0.6.RELEASE"
}
group 'xyz.transformercli'
version '1.0-SNAPSHOT'
sourceCompatibility = 11
repositories {
mavenCentral()
}
dependencyManagement {
imports {
mavenBom 'io.micronaut:micronaut-bom:1.0.3'
}
}
dependencies {
annotationProcessor "io.micronaut:micronaut-inject-java"
//my jar with base classes
compile files('libs/transformer-cli-0.1.jar')
compile "io.micronaut:micronaut-inject"
}
Hi @graemerocher I'm using a third party Jar from Maven central that contains@Inject statements.
Not sure if the jar it self was compiled using annotation processors.
Does the main project needs to be using annotation processors or the dependency jar itself ?
Most helpful comment
Hi @graemerocher I'm using a third party Jar from Maven central that contains
@Injectstatements.Not sure if the jar it self was compiled using annotation processors.
Does the main project needs to be using annotation processors or the dependency jar itself ?