【发布时间】:2017-08-22 00:54:48
【问题描述】:
我正在尝试将一些代码转换为新格式,并且遇到了 dropwizard 资源的问题。这是我添加的资源类注入
@Inject
public TestResource(TestDAO testDAO, String path) {
TestDAO 是一个扩展 io.dropwizard.hibernate.AbstractDAO 的类。当我尝试通过注入运行它时,我收到了
1) Explicit bindings are required and ...TestDAO is not explicitly bound.
while locating ...TestDAO
for the 1st parameter of TestResource.<init>(TestResource.java:44)
2) Explicit bindings are required and java.lang.String is not explicitly bound.
while locating java.lang.String
for the 2nd parameter of ...TestResource.<init>(TestResource.java:44)
【问题讨论】:
-
你认为你在哪里明确绑定了这些参数
-
我从来没有说过我以为我是。我不知道我需要为显式绑定做什么。我是 Java 新手。我查看了使用它的其他项目和文档,但没有看到我应该添加什么。
标签: java guice code-injection