问题
I'm trying to set a root context path for my application in `conf/application.yml' like so:
server:
'context-path': '/'
However, when trying to start grails> run-app
, I get the following exception:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':bootRun'.
> Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
回答1:
From Grails 3.0.3, the expected configuration key is contextPath, camel case and not hyphenated. So the right setting in your application.yml
is:
server:
contextPath: '/my-path'
Or, if you're using application.groovy
:
server.contextPath='/my-path'
回答2:
I should have paid more attention to the error log output from run-app
. The correct setting is:
server:
'context-path': ''
>= Grails 3.0.3:
server:
contextPath: ''
来源:https://stackoverflow.com/questions/29721715/how-to-set-a-grails-3-app-to-use-a-root-context-path