更新时间:2023-11-19 19:24:16
视图已预编译为可通过Gradle和compileGsonViews
任务进行部署的类.默认情况下,这是使用project.name
设置完成的.
Views are pre-compiled into classes for deployment via Gradle and the compileGsonViews
task. This is done using the project.name
setting by default.
您会在build/main/gson-classes
目录中注意到所生成的类.例如,如果您的应用程序名称为foo
,则将具有类似foo_book_show_gson.class
的类,其中foo_
部分被视为程序包"名称.
You will notice in the build/main/gson-classes
directory the classes that are produced. For example if your application name is foo
you will have classes like foo_book_show_gson.class
where the foo_
part is considered the "package" name.
在运行时.包名称,用于解析根据grails-app/conf/application.yml
中的info.app.name
设置计算的视图.
At runtime. The package name to use to resolve views calculated from the info.app.name
setting in grails-app/conf/application.yml
.
这意味着,如果在Gradle中您的project.name
评估为foo
,并且application.yml
中的设置也是foo
,那么一切都很好.这是最常见的情况,因为通常您的应用程序名称在两个地方都是相同的.
What this means is that if in Gradle your project.name
evaluates to foo
and the setting in application.yml
is also foo
then all is well. This is the most common case as typically your application name is the same in both places.
如果info.app.name
和Gradle project.name
不匹配,则会出现视图无法解析的问题.
If info.app.name
and the Gradle project.name
don't match up you can get the problem where views don't resolve.
您有两个选择可以解决此问题.一种是修改build.gradle
以显式指定程序包名称:
You have two options to fix this. One is to modify build.gradle
to explicitly specify the package name:
compileGsonViews.packageName = 'foo'
然后确保info.app.name
与该值匹配.
Then make sure info.app.name
matches that value.
第二个选项是重命名项目目录,以便info.app.name
和project.name
对齐.
The second option is rename your project directory so that info.app.name
and project.name
align.