0
我在eclipse中有一個可用的動態Web項目(JAX-RS),它從數據庫獲取記錄並以json格式返回數據。WELD-001408不滿意的依賴注入點
現在,我想把這個項目分成兩部分。
1. CompDB //Project stores database handlers classes
src
database
ComponentContext.java
ComponentViewable.java //Interface
database.uat
ComponentUATView.java //Implements ComponentViewable
META-INF
persistance.xml
WebContent
WEB-INF
beans.xml
web.xml
創建一個jar文件,並複製到項目2的WEB-INF/lib目錄,如下
2. CompRS //Project stores JAX-RS client classes
src
compreport
ComponentData.java
META-INF
persistance.xml
WebContent
WEB-INF
lib
CompDB.jar
beans.xml
web.xml
當我glssfish 3.1上運行CompRS,得到下面的錯誤
INFO: WEB0671: Loading application [CompRS] at [/CompRS] SEVERE: Exception while loading the app
INFO: file:/C:/Program Files/glassfish-3.1.2.2/glassfish/domains/domain1/eclipseApps/CompRS/WEB- INF/lib/CompDB.jar_ci logout successful
SEVERE: Exception while loading the app : WELD-001408 Unsatisfied dependencies for type
[ComponentViewable] with qualifiers [@ComponentContext] at injection point [[field] @Inject @ComponentContext compreport.ComponentData.componentdata]
這裏是代碼
ComponentData.java
@Path("component")
@RequestScoped
public class ComponentData {
@Inject @ComponentContext ComponentViewable componentdata;
@GET
@Path("latest")
@Produces("application/json")
....
}
ComponentContext.java
@Target({TYPE,METHOD,PARAMETER,FIELD})
@Retention(RUNTIME) @Documented @Qualifier
public @interface ComponentContext{}
我很新創建多個罐子和整合他們。如果這不是正確的方法,請指導我實現。
哇,它的工作。非常感謝。 – user2397194