Java EE RESTful 服务领域注入
Java EE RESTful Service field Injection
我在 wildfly 中部署应用程序时遇到问题,其中包含一个 RESTful 使用 @Inject 注入 DAO 的服务。
这是尝试在 wildfly 中部署应用程序时日志中的错误消息:
Deploying /home/john/codebase/servers/wildfly-8.2.0.Final/standalone/deployments/HouseCompetitionDashboard-1.0-SNAPSHOT.war
{"JBAS014671: Failed services" => {"jboss.deployment.unit.\"HouseCompetitionDashboard-1.0-SNAPSHOT.war\".WeldStartService" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"HouseCompetitionDashboard-1.0-SNAPSHOT.war\".WeldStartService: Failed to start service
Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type DAO with qualifiers @Default
at injection point [BackedAnnotatedField] @Inject private org.jmcdonnell.dashboard.services.PlayerService.dao
at org.jmcdonnell.dashboard.services.PlayerService.dao(PlayerService.java:0)
"}}
classes 看起来像这样:
@Named
public class DAO {
}
@Stateless
@Path("player")
public class PlayerService {
@Inject
private DAO dao;
@POST
@Consumes({"application/xml", "application/json"})
public void create(Player entity) {
//dao.create(entity);
}
}
稍后在 DAO class 上将包含一个实体管理器,但目前它还没有,因为我至少希望让注入工作。有人有什么想法吗?
@Named
annotaion 需要一些名称,但未设置名称 - 它生成默认名称,但是,名称会根据 bean 的驼峰命名法生成。您需要尝试指定名称或使用驼峰命名法作为 bean 名称。
我在 wildfly 中部署应用程序时遇到问题,其中包含一个 RESTful 使用 @Inject 注入 DAO 的服务。
这是尝试在 wildfly 中部署应用程序时日志中的错误消息:
Deploying /home/john/codebase/servers/wildfly-8.2.0.Final/standalone/deployments/HouseCompetitionDashboard-1.0-SNAPSHOT.war
{"JBAS014671: Failed services" => {"jboss.deployment.unit.\"HouseCompetitionDashboard-1.0-SNAPSHOT.war\".WeldStartService" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"HouseCompetitionDashboard-1.0-SNAPSHOT.war\".WeldStartService: Failed to start service
Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type DAO with qualifiers @Default
at injection point [BackedAnnotatedField] @Inject private org.jmcdonnell.dashboard.services.PlayerService.dao
at org.jmcdonnell.dashboard.services.PlayerService.dao(PlayerService.java:0)
"}}
classes 看起来像这样:
@Named
public class DAO {
}
@Stateless
@Path("player")
public class PlayerService {
@Inject
private DAO dao;
@POST
@Consumes({"application/xml", "application/json"})
public void create(Player entity) {
//dao.create(entity);
}
}
稍后在 DAO class 上将包含一个实体管理器,但目前它还没有,因为我至少希望让注入工作。有人有什么想法吗?
@Named
annotaion 需要一些名称,但未设置名称 - 它生成默认名称,但是,名称会根据 bean 的驼峰命名法生成。您需要尝试指定名称或使用驼峰命名法作为 bean 名称。