Groovy 没有 tomcat 或任何其他 servlet 容器的 Grails 独立应用程序

Groovy Grails standalone application without tomcat or any other servlet container

我是 groovy/grails 的新手,想制作一个 独立应用程序 仅利用 Grails,即一个没有Servlet 容器。

可以在 spring 中使用 @SpringBootApplicationSpringApplication.run() 并将其添加到 Maven pom.xml

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
    <exclusions>
        <exclusion>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
        </exclusion>
    </exclusions>
</dependency>

是否可以在不使用 springBoot 的情况下仅在 Grails 中完成此操作?
如果是,如何?
如果没有,为什么不呢?

查看 Grails tag

Grails is an Open Source, full stack, web application framework that ...

如果不是网络,那么使用 Grails 就没有多大意义。我想,您对 CLI 应用程序感兴趣。我建议 Micronaut, instead; particularly, refer to the section, Standalone Command Line Applications.

有用的资源:

如前所述,Grails 通常不会 运行 在 JEE 容器之外。

另一方面,理论上您可以创建一个 Fat Jar,将其嵌入 tomcat/jetty 和 运行 打包为一个独立的 jar。它可能会起作用,但我没有测试它。

如果您想采用无黑客攻击的方式,您可以选择 Micronaut 作为最接近的 Grails 替代方案,它在 netty 上 运行ning,因此不需要容器。

另一种选择是使用 Ratpack,它也是 Groovy 风味且基于 netty

我最近在混合 standalone GORM and Vert.x 方面有一些很好的经验(我对异步有一些特定的要求)