使用mn create-app生成Groovy服务应用得到Java类,是否会改为Groovy类?
Hey there, let's break this down for you:
First, to confirm what you're seeing: yes, when you run mn create-app my-groovy-app -features=groovy, the generated Application class is indeed Java-based. This is the current default behavior of the Micronaut CLI—even with the groovy feature enabled, the main entry point remains a Java class, while other scaffolded components (like controllers or services) will use Groovy.
As for whether this will change down the line: right now, there's no public roadmap indicating the Micronaut team plans to alter this default. That said, you don't have to stick with the Java class if you don't want to—switching to a Groovy-based entry point is straightforward:
- Delete the auto-generated
src/main/java/my/groovy/app/Application.javafile - Create a new
Application.groovyfile undersrc/main/groovy/my/groovy/app/with this code:package my.groovy.app import io.micronaut.runtime.Micronaut class Application { static void main(String[] args) { Micronaut.run(Application, args) } }
If you'd prefer the CLI to handle this out of the box, you could always submit a feature request to the Micronaut GitHub repository. The team often considers community feedback when prioritizing changes like this.
内容的提问来源于stack exchange,提问作者Dan

