English 中文(简体)
将格罗莫夫·格列斯投进 Java门
原标题:Injecting a Groovy Grails-service into a Java class

我在格罗莫夫实施了一项铁路服务,我愿意在网络应用中将这一服务注入贾瓦语。 我知道,我可以通过“Context.getBean”(“exampleservice”)在 Java获得信条,但是,在汇编时间时,“Exampleservice”型号并不为人所知。

我能否进口这项服务? 这似乎并没有宣布一个典型的一揽子计划。

(I m fairly new to Grails and the Java Web so anything to help my understanding of what s going on behind the scenes here is greatly appreciated.)

最佳回答

所建议的做法是将铁路服务引向一个接口,然后通过春天将这一服务投放到你们的ava。 见用户指南——

问题回答

如果你不使用<条码>申请目录>,将Grails服务注入 Java类别,则 Java类本身必须成为春天,你应在<条码>资源.groovy或<条码>上将这两条连接起来。

如果上述情况对你有重大意义,你可能会想谈谈春天依赖注射的基础。

接着Dónal说的话,你可以把Java语作为资源的一个灯塔。 gro

例如,可以说, your木阶级的名称是JavaClass,它位于你的弧切身之处。 争取资源。 gro牛,并添加以下内容:

beans = {
...
    javaClass(JavaClass) {
        exampleService = ref( exampleService )
    }
}

现在,你们应该能够学习榜样。 a. 固定床位等舱内服务。

def exampleService

虽然铭记,如果你使用像内识这样的东西的话,那么光灯可能不会出现在后面。 这是正常的。 此外,不要忘记将JavaClass输入资源。 gro





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签