Launching a grails-app through Intelli-J with root

2019-04-13 05:34发布

Is there a way to launch an application through Intelli-J so that it makes localhost:8080/ the root of the application? The problem I'm having is that AJAX urls that work locally don't work in production, and createLink(action:"ajaxUpdate") seems to create references to /app/ajaxUpdate, which works locally but not in production.

Is there a way to fix createLink to work in both locations? I thought perhaps I could just use UrlMappings to make all the ajax calls pretty and just refer to /ajaxUpdate, but that doesn't work because of how the grails application is deployed within Intelli-J.

How do I fix this?

1条回答
Bombasti
2楼-- · 2019-04-13 06:10

About your problem, in grails-app/conf/Config.groovy you can specify the server URL, like this:

environments {
    production {

        grails.serverURL = "http://localhost/"  // Specify the "root" of your link
        ....
    }

    development {
        grails.serverURL = "http://localhost:8080/${appName}"
        ...
    }
    ...
}

Then the createLink method should be fine. As I know, it's about Grails config, not relate to IntelliJ.

EDIT: It seems that I missed some information: to make the createLink start at "http://localhost/", it's necessary to add another line into Config.groovy:

grails.app.context = "/"
查看更多
登录 后发表回答