grails更改端口号

3.0.9版本:

grails run-app --port=9000
server:
     port: 9000
     context-path: '/xxx' #指定程序启动后的名字。即: http://localhost:9000/xxx   使用'/@info.app.name@' 出来的不是项目名称。

以下来自于 搜索内容:亲测有效果
grails改变端口号:

更改Grails默认服务端口

从命令行运行Grails应用程序(例如使用grails run-app)时,默认情况下它将在8080端口上运行。但是有些时候服务器的8080端口已经被其他应用程序占用,这时它将会报错:

Server failed to start: LifecycleException: Protocol handler initialization failed: java.net.BindException: Address already in use: JVM_Bind:8080

更改Grails应用程序运行端口的方法有几种。

1. 在命令行使用-Dserver.port参数指定运行端口:

grails -Dserver.port=9000 run-app

2. 永久性改变项目的运行端口:
You can change the port for your project so that every time you run the project, it runs on a new port without having to add command line arguments.

To do this, go to the root directory for your project and then change into the grails-app/conf directory. Create a new file called BuildConfig.groovy (or edit the existing file if there is already one there) and add this line to the file:

grails.server.port.http = 9000

The nice thing about this approach is that if you have multiple grails projects you are working on, you can assign them all to a different port and have them running at the same time.
这种方法的优点是可以为多个同时运行的项目分别设置不同的端口。

  1. 修改用户的默认设置:
    To change the default so that projects always use the 9000 port instead of 8080, go into the .grails directory in your home directory. This is your home directory on your computer, not the grails or grails project home directory. Also note that this directory gets created once you run a grails application. If the directory does not exist, run your grails application and it will get created.

In the .grails directory, create a file called settings.groovy (or edit the existing file if there is one there already) and add the following line:

grails.server.port.http = 9000

With this line added, it will change the default port used by all grails projects on your machine that make use of the default port.

这种方法将使得该用户所运行的Grails应用默认在9000端口上运行。

  1. 修改Grails程序的默认设置:
    Another solution is to change the default port used by Grails itself. In Grails 1.1 at least, the trick is to modify the $GRAILS_HOME/scripts/_GrailsSettings.groovy file. In it, you will find a reference to the default port (8080). Just change it to whatever you require, and Grails will always run on this new port. The modified entry might look like this:

serverPort = getPropertyValue(“server.port”, 9000).toInteger()

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值