我正在尝试从 Glassfish+Jersey+Weld 迁移到 Jetty。
我有这样的设置:pom.xml、web.xml 和 Java 启动器的要点。
应用程序似乎可以正常启动,但是在处理任何请求时,我看到应该由 Weld ( logger
) 注入的字段为空。
@RequestScoped
@Path("/foobar")
@Consumes({ ExtendedMediaType.APPLICATION_JSON,
ExtendedMediaType.APPLICATION_JAVASCRIPT })
@Produces({ ExtendedMediaType.APPLICATION_JSON,
ExtendedMediaType.APPLICATION_JAVASCRIPT })
public class EmailResource extends {
@Inject
private Logger logger;
@Override @POST
public Response create(EmailJob document)
throws URISyntaxException, ResourceException
{
logger.debug("Hi there!");
}
}
问题是什么?
更新:记录器生产者看起来很可疑,但它甚至没有被调用:
/** This class uses CDI to alias Java EE resources into CDI beans. **/
public class Resources {
@Produces
public Logger produceLog(InjectionPoint injectionPoint) {
return LoggerFactory.getLogger(
injectionPoint.getMember().getDeclaringClass().getName());
}
}