Grails 3 - change default port for run-app

安稳与你 提交于 2019-11-29 02:53:39

You can use

server:
  port: 9001

in application.yml.

Or you can pass it via system environment. (e.g. SERVER_PORT=9001 grails run-app).

grails run-app --port=8081

Or in interactive mode:

run-app --port=8081

Don't forget to use the same port when you want to stop the server:

stop-app --port=8081

I believe this feature was broken in 3.0.3 and earlier versions but it definitely works in 3.0.4.

Accepted answer is correct. For some additional info, Grails 3 uses spring-boot and the server properties are configured by the

org.springframework.boot.autoconfigure.web.ServerProperties

class. "port" is just a property on this class which is filled from the application.yml with the prefix "server". So in addition to the port, you can set properties of this class including tomcat configuration properties and etc. To change the contextPath for instance you add

server: 
   contextPath: /myapp

to you application.yml.

  server:
  port: 9809
  contextPath: '/admin/'

you can use this in your application.yml file

or change the port depends on the environment for example :

    environments:
        test:
            grails:
                serverURL: "http://localhost:9809"
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!