我正在使用 tomcat 在 Weld CDI 上设置应用程序,并尝试在应用程序启动时运行一个类来启动实体管理器。我收到以下异常绞盘,表明我的班级不止一个范围。
WELD-000046 At most one scope may be specified on public@ApplicationScoped @Singleton class se.raindance.squid.core.init.InitSquid
这是我的 InitSquid.Java
@ApplicationScoped
@Singleton
@Startup
public class InitSquid {
@Inject
private Logger log;
@Inject
EntityManager entityManager;
/**
*
* @param startupEvent is sent when JSF is ready and up and running( After first
* request to FacesServlet).
*/
@PostConstruct
public void init() {
System.out.println("stutrup!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! InitSquid");
// Init Rainlets
InitRainlets initRainlets = new InitRainlets(entityManager);
initRainlets.init();
initSquidSettings();
}
private void initSquidSettings() {
List<SquidSettings> settingsList = (List<SquidSettings>) entityManager
.createQuery(
"select squidsettings from SquidSettings squidsettings")
.getResultList();
if (settingsList.size() == 0) {
log.info("No SquidSettings entity exists in system, creating one");
SquidSettings settings = new SquidSettings();
settings.setSubledgerRestResourceURI("http://localhost:8080/subledger-webapp/resteasy/");
entityManager.persist(settings);
}
}
}
我将不胜感激有关此问题的任何提示