您如何更改 Grails 3 中的应用程序名称? [英] How do you change the application name in Grails 3?

查看:24
本文介绍了您如何更改 Grails 3 中的应用程序名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是使用 Gradle 和 Grails 3.x 的初学者.在 Grails 2.x 中,appName 可以在 application.properties 文件中更改,现在在 Grails 3.0.8 中,文档解释说它可以在 application.yml 但我找不到更改 appName 的方法.

I'm a beginner using Gradle and Grails 3.x. In Grails 2.x appName could be changed in the application.properties file, now in Grails 3.0.8 the docs explain that it's possible in application.yml but I can't find a way to change appName.

推荐答案

应用程序名称在 Grails 3 中几乎无关紧要.它在您创建 WAR 文件时用作基本名称,但在部署之前重命名它是微不足道的,你可能会不管,因为它包括应用程序版本.

The application name is nearly irrelevant in Grails 3. It is used as the base name when you create a WAR file, but it's trivial to rename it before deploying, and you probably would regardless since it includes the application version.

它用作 grails.codegen.defaultPackage 配置设置的初始值,但您可以轻松更改:

It's used as the initial value of the grails.codegen.defaultPackage config setting, but you can change that easily:

grails:
   codegen:
      defaultPackage: 'com.foo.bar'

但我不会为此烦恼,因为我不使用默认包 - 我为每个工件指定包以避免最终将所有内容都放在一个包中.

But I wouldn't bother with that since I don't use a default package - I specify the package for every artifact to avoid ending up with everything in one package.

在旧版本的 Grails 中,它被用作通过 run-app 运行应用程序时的默认上下文,例如http://localhost:8080/appname 但在 Grails 3 中使用的是 Spring Boot 的默认行为,并且默认没有上下文.但是如果你想指定 run-app 上下文,你可以这样做(以及可选的端口):

In older versions of Grails it was used as the default context when running the app via run-app, e.g. http://localhost:8080/appname but in Grails 3 the default behavior of Spring Boot is used and there's no context by default. But if you want to specify the run-app context, you can do that (and optionally the port) with:

server:
   contextPath: /wheeeeeeee
   port: 9090

Gradle 的默认行为是使用目录名称作为其项目名称.如果你想覆盖它,创建一个 settings.gradle 文件并设置 rootProject.name 属性:

Gradle's default behavior is to use the directory name as its project name. If you want to override that, create a settings.gradle file and set the rootProject.name property:

rootProject.name = 'custom_app_name'

这篇关于您如何更改 Grails 3 中的应用程序名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆