Grails changes port running

Source: Internet
Author: User
Tags grails

Changing the grails default server port
Change grails default service port

Run the grails application from the command lineProgramFor example, when grails run-app is used, it runs on port 8080 by default. However, when port 8080 of the server is occupied by other applications, an error is reported:

Server failed to start: lifecycleexception: protocol handler initialization failed: java.net. bindexception: address already in use: jvm_bind <null>: 8080

There are several methods to change the grails application running port.

 

1. Use the-dserver. Port parameter in the command line to specify the running Port:

Grails-dserver. Port = 9000 run-app

2. permanently change the running port of the project:
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.

 

The advantage of this method is that you can set different ports for multiple projects running at the same time.

 

3. Modify the user's default settings:
To change the default so that projects always use the 9000 port instead of 8080, go into. 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.

 

This method makes the grails application running by the user run on port 9000 by default.

4. Modify the default settings of the grails program:
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 ()

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.