如何在 java SE 和 jersey 中替换注解 @Dependent 和 @ApplicationScoped?

How to replace annotation @Dependent and @ApplicationScoped in java SE and jersey?

我用java 8 SE 和球衣。我找到了 jwt 服务的示例 here, 有使用 java 6 EE。 有人知道此注释的类似物或此问题的其他解决方案吗?

我通过替换@Singelton 上的注释并添加

解决了这个问题

ApplicationBinder

public class ApplicationBinder extends AbstractBinder {
    @Override
    protected void configure() {
        bind(UserService.class).to(UserService.class).in(Singleton.class);
    }
}

资源配置

public class ApplicationConfig  extends ResourceConfig {
    public ApplicationConfig() {
        register(new ApplicationBinder());
        packages(true, "api");
    }
}

比我只能通过注解@Inject

注入bean-classes