问题
What started as a roadblock to setup a new Micronaut project with corporate repo, is now more about curiosity of how Embedded server is bootstrapped. I have a Micronaut CLI generated project with com.github.johnrengelman.shadow
gradle plugin which works fine when I run the jar using-
$ java -Dmicronaut.environments=E1 -jar build/appBundle/app.jar
build.gradle-
plugins {
id "com.github.johnrengelman.shadow" version "5.0.0"
}
...
shadowJar {
mergeServiceFiles()
}
When I replace shadow
plugin/task with jar
task and java
plugin, then I am able to create an executable fat-jar , but it fails with following error-
$ java -Dmicronaut.environments=E1 -jar build/appBundle/app.jar
16:12:22.662 [main] INFO i.m.context.env.DefaultEnvironment - Established active environments: [E1]
16:12:22.863 [main] INFO io.micronaut.runtime.Micronaut - No embedded container found. Running as CLI application
build.gradle-
plugins {
id "java"
}
...
jar {
manifest {
attributes "Main-Class": "axp.payments.pci.dss.PaymentsPciDssDispatcher"
}
from {
configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
}
- What I would like to understand is how the embedded server bean is getting injected with shadow plugin but not otherwise?
- How to create a
fat-jar
with embedded Netty server and without usingcom.github.johnrengelman.shadow
gradle plugin?
来源:https://stackoverflow.com/questions/58755410/how-to-create-micronauts-fat-jar-without-shadow-plugin