问题标签 [grails3.2.0]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
246 浏览

hibernate - GrailsDomainBinder.getMapping(Doamin) 在 Grails-3.2.4 中为非持久域返回 null

我有两个域。

在 Grails 2.5.5 中,下面的行工作得很好,但是在进行了所需的更改后,它在 Grails-3.2.4 中不起作用并且给出了 null。

请帮助我从 XYZ 域获取映射对象。

我的发现:

我在 application.yml 中使用带有注释#dbCreate:''的 oracle db 。

在 XYZ 域中评论static mapWith = "none"后,我得到了 Mapping 对象,并且由于#dbCreate:'' ,因此未在 DB 中创建相应的表。

这种方法有什么问题吗?如果是,请为我提供替代解决方案。

0 投票
2 回答
313 浏览

grails - Grails 3 UrlMappings

你如何映射一个有两个 id 的 Url:

/orders/$id1/orderlines/$id2

id2 是可选的

/orders/$id1/orderlines GET -> 订单 id1 的所有订单行 /orders/$id1/orderlines/$id2 GET -> 在订单 id1 中显示订单行 id2

这些方法将被映射到 OrderLineController

使用 Spring MVC @RequestMapping 和 @PathVariable 非常容易。

Grails 3 不允许@RequestMapping(有一些技巧可以让它工作——但我不想走那条路——不必要的复杂)。

感谢帮助。我做了很多谷歌搜索。

0 投票
1 回答
626 浏览

grails - 静态方法的“需求”不适用于 Grails-3.2.4“Junit 测试”中的“新 MockFor”

谁能告诉我如何要求一个类的静态方法。我已尝试使用以下代码,但无法使用:

有了这个,它给出了以下例外:

有人可以指出我如何使用 grails 3 在 JUNIT 中模拟静态方法。

0 投票
1 回答
222 浏览

grails - Grails 3 WAR 部署服务器先决条件

我是 Grails (v 3.2.3) 的新手,我想知道 grails 3 WAR 实际上通常需要在服务器上运行哪些先决条件:

我只需要安装 Tomcat 和 JRE,还是需要安装其他安装,例如 GDK 和 grails?

我试图从文档中弄清楚 http://docs.grails.org/3.2.3/guide/deployment.html#deploymentContainer

这里说:

应用服务器

理想情况下,您应该能够简单地将 Grails 创建的 WAR 文件拖放到任何应用程序服务器中,它应该可以立即工作。然而,事情很少这么简单。Grails 网站包含一个已测试 Grails 的应用程序服务器列表,以及使 Grails WAR 文件正常工作所需的任何其他步骤。

该 URL 受到保护,即使在设置帐户后我也无法访问:https ://grails.org/Deployment

我知道这可能与“部署 grails Web 应用程序的最低要求”重复,但我更愿意在向“错误的”网络托管商下订单之前收集有关此主题的一些官方背景。

更新

非常感谢您的回复。现在我也找到了这些,所以很明显 grails WAR 甚至可以作为“独立”Java 应用程序运行

http://docs.grails.org/3.2.3/guide/gettingStarted.html#deployingAnApplication

http://docs.grails.org/3.2.3/guide/gettingStarted.html#supportedJavaEEContainers

0 投票
1 回答
650 浏览

tomcat - 无法启动应用程序:grails 3 + tomcat 8

我正在尝试在 tomcat8 上部署和运行我的应用程序,部署似乎没问题,但是当我访问应用程序时:

Catalina.out:

请建议,如何调试这种行为

0 投票
0 回答
293 浏览

grails - Grails 3.2.6 - 修改 BootStrap.groovy 中的控制器渲染方法

目前正在将应用程序从 Grails 2.4.5 迁移到 Grails 3.2.6。我们需要在渲染之前修改模板路径的能力,并在 Grails 2 BootStrap.groovy 中完成了这项工作:

然而,修改后的 render 方法似乎从未在 Grails 3.2.6 中被调用。有什么建议么?如果有更好的解决方案,我愿意以其他方式覆盖渲染方法。. .

0 投票
2 回答
1085 浏览

grails - Rendering json views from controller in Grails

I found that Grails 3.2+ supports json views which provides an elegant way for the response to have json.

So is there a way such that instead of having the ".json" in the request URL, we render a custom JSON template from the controller. I tried using the render method, but keep getting an error that the template could not be found. Additionally reading through the documentation I can't seem to find a way to do this. Is this something that is supported yet?

0 投票
1 回答
239 浏览

grails - 验证约束 importFrom 抛出异常

尝试从使用共享约束的域类导入约束时,我得到以下异常。绑定阶段出现异常

例外:

领域:

命令

堆栈跟踪:

有任何想法吗 ?

0 投票
0 回答
11 浏览

oauth-2.0 - 如何在不使用插件的情况下在 grails 中向 google 进行身份验证

我一直在使用 grails oauth2 插件对谷歌进行身份验证,但想知道是否有任何方法可以在不使用任何插件的情况下使用谷歌身份验证,例如使用 HttpBuilder 向谷歌发出请求。

0 投票
1 回答
406 浏览

grails - Grails 3:doWithSpring 中的覆盖服务

在 grails 2 中,重写 XPlugin.groovy 中的 bean 只需要在 doWithSpring() 方法中重新定义服务:

我开始在 Grails 3 中编程,已经使用过 Grails 2,并在新插件中尝试了相同类型的覆盖,因为我正在为我现有的一些 Grails 2 插件创建 Grails 3 版本:

我做了一些集成测试:

运行测试时,我收到错误:

我的 TokenStorageProxyService 似乎没有覆盖默认的 JwtTokenStorageService,导致在将服务连接到集成测试时出现 ConversionNotSupportedException。如何覆盖插件中的服务?