私は会社でプロジェクトに取り組んでおり、オブジェクトの注入に問題があります。このエンティティプロバイダーがあると考えてみましょう:
@Stateless
@TransactionManagement
public class EntityProviderBean<T> extends CachingMutableLocalEntityProvider<T> {
public EntityProviderBean(Class<T> entityClass) {
super(entityClass);
setTransactionsHandledByProvider(false);
}
@PersistenceContext(unitName = CoreApplication.PERSISTENCE_UNIT)
private EntityManager em;
@Override
@TransactionAttribute(TransactionAttributeType.REQUIRED)
protected void runInTransaction(Runnable operation) {
super.runInTransaction(operation);
}
@PostConstruct
public void init() {
setEntityManager(em);
setEntitiesDetached(false);
}
}
上記のエンティティー・プロバイダーを使用して拡張された JPAContainer
@UIScoped
public class IncidentContainer extends JPAContainer<Incident> {
private static final long serialVersionUID = 8360570718602579751L;
@Inject
EntityProviderBean<Incident> provider;
public IncidentContainer() {
super(Incident.class);
}
@PostConstruct
protected void init() {
setEntityProvider(provider);
}
}
問題は (そして私はそれを理解しています)、inject メソッドには空のコンストラクターが必要なため、クラス型定義で @Inject オブジェクトを実行できないことです。それを機能させる方法のいくつかの解決策はここにありますか? 今、私は例外を受けています
org.apache.webbeans.util.InjectionExceptionUtils.throwUnsatisfiedResolutionException(InjectionExceptionUtils.java:77)
答えてくれてありがとう:)オンドレイ