对于类型X的不满意的依赖关系,在注入点使用限定符@Default [BackedAnnotatedField] @Inject @Default

时间:2017-07-17 18:44:58

标签: java dependency-injection ejb cdi

我正面临注射问题。

我已经删除了文件以提供我正在做的事情的基本概述。

UsersApi.java(REST服务)

package com.example.api;
@Path("/users")
@RequestScoped
public class UsersApi  {
  @Inject
  private UsersService delegate;
  @GET
  @Path("/{lanId}")
  @Consumes({ "application/json" })
  @Produces({ "application/json" })
  public Response userDetails(userID,httpServletRequest){
    Response userDetails= delegate.userDetails(userID,httpServletRequest);

    return Response.ok(userDetails,MediaType.APPLICATION_JSON_TYPE).build();
    }
}

UsersService.java

   package com.example.api;
    public interface  UsersService {
    public  Response userDetails(String lanId, HttpServletRequest httpServletRequest);
    }

UsersServiceImpl.java

package com.example.api.impl;
@Stateless 
public class UsersApiServiceImpl implements UsersApiService {
    @Override
    @TransactionAttribute(TransactionAttributeType.REQUIRED)
    public Response userDetails(String lanId, HttpServletRequest httpServletRequest) {
    System.out.println(lanId);
    }
}

当我在weblogic中部署ear文件时,它会抛出

Unsatisfied dependencies for type UsersService with qualifiers @Default at injection point [BackedAnnotatedField] @Inject @Default private com.example.api.UsersApi.delegate at com.example.api.UsersApi.delegate(UsersApi.java:0)

0 个答案:

没有答案