如何设置grails 3应用程序以使用根上下文路径?

时间:2015-04-18 19:19:11

标签: grails grails-3.0

我试图在`conf / application.yml'中设置我的应用程序的根上下文路径。像这样:

server:
    'context-path': '/'

但是,在尝试启动grails> run-app时,我遇到以下异常:

失败:构建因异常而失败。

* 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

2 个答案:

答案 0 :(得分:6)

来自Grails 3.0.3,source code,骆驼的情况,而不是连字符。因此,server: contextPath: '/my-path' 中的正确设置是:

application.groovy

或者,如果您使用server.contextPath='/my-path'

if (File.Exists(pathToMyFile))
{
   try
   {
      using (var fs = new FileStream(pathToMyFile, FileMode.Open, FileAccess.Read))
      {
         BinaryReader br = new BinaryReader(fs);
         Byte[] bytes = br.ReadBytes((Int32) fs.Length);
         br.Close();
         fs.Close();
         myFile = Convert.ToBase64String(bytes);
      }
   }
   catch
   {
      // Log exception
   }
}

答案 1 :(得分:2)

我应该更加关注run-app的错误日志输出。正确的设置是:

server:
    'context-path': ''

> = Grails 3.0.3:

server:
    contextPath: ''