简体   繁体   中英

How do you change the application name in Grails 3?

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 .

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.

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.

In older versions of Grails it was used as the default context when running the app via run-app , eg 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'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'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM