postconstruct

    0熱度

    1回答

    我用我想測試的方法創建了一個bean。不幸的是,它是一個帶有PostConstruct註釋的bean。我不想調用PostConstruct方法。 我該怎麼做? 我試過2種不同的方法(如下面的例子所示),但沒有工作; init()仍然被調用。 有人能給我一個詳細的例子,說明如何做到這一點? DirBean.java @Singleton @Startup public class DirBean

    2熱度

    1回答

    我有一個EJB模塊,它使用ActiveMQ-Core 5.7.0作爲它的依賴項。當我將EJB Module單獨部署到Glassfish服務器4.1時,可以成功部署它。但是,當我包括在企業應用這個EJB模塊和部署此EAR到服務器時,它拋出錯誤: [glassfish 4.1] [SEVERE] [] [javax.enterprise.system.core] [tid: _ThreadID=48

    1熱度

    4回答

    我正在使用Spring Boot,並將@PostConstrcut註釋添加到我的JPA實體中(如圖所示),但是當實體被實例化時,此攔截器永遠不會被調用。 @Entity public class MyTableName implements java.io.Serializable { // all attributes @PostConstruct public

    0熱度

    1回答

    我遇到以下情況,我正在運行到空指針異常,因爲bean未初始化並導致失敗,導致我的服務器無法啓動。 在PostConstruct註釋的方法中有一個新引入的調用失敗。另一種不在PostConstruct中的方法正在執行相同的調用,該方法正確執行並且不會引起任何問題。 @Component @Lazy @Primary class Parent{ @Autowired private Desi

    0熱度

    1回答

    我的@PostConstruct方法符合所有規則,但我仍然得到錯誤,該方法不是EJB攔截器的構造後方法。 它的回報是無效的。它不會拋出異常。它不需要論據。 有誰知道另一個原因,這個錯誤可能發生? import javax.annotation.PostConstruct; ... @PostConstruct public void init() { getRef

    1熱度

    2回答

    是否可以取消在@PostConstruct階段創建視圖?我有: @PostConstruct public void createPartControl(Composite parent) { try { // do something where an exception is thrown } catch (Exception e) { // I

    1熱度

    1回答

    我想用@PostLoad中的數據庫加載其他數據來豐富實體。 如何訪問@PostLoad方法中的Spring managed beans? 我用靜態訪問醜陋的解決方案: @Service public class StaticApplicationContext implements ApplicationContextAware { private static Application

    1熱度

    1回答

    我有以下類別: @Repository class A { public void method1() { ... } } @Component class B implements C { @Autowired @Lazy private A a; public void method2() {

    0熱度

    1回答

    由組件掃描自動創建以明確地定義豆豆,能夠定義init和通過註解破壞方法中,在彈簧配置類: @Configuration @ComponentScan public class Appconfig { @Bean(name="Andre",initMethod="init",destroyMethod="destroy") @Scope("singleton") p

    2熱度

    2回答

    我一直在試圖解決一個問題,我的managedBean有時是空的(我得到了目標不可達錯誤消息,說bean是空的),這個間歇性問題通常發生在我修補程序在@PostConstruct方法中。 在啓動應用程序時,我確實沒有看到任何錯誤,但只要我嘗試通過XHTML與BOOM進行交互,BOOM! Bean是空的。我閱讀了@PostConstruct文檔,它說如果發生異常,「這個bean沒有投入使用」,這是否意