2015-09-07 56 views
0

我在我的項目中使用JPA ecilpse鏈接。以下是我的pom.xmljsf faces在部署到wildfly時Inject不工作

<groupId>sms</groupId> 
<artifactId>sms</artifactId> 
<version>1.0-SNAPSHOT</version> 
<packaging>war</packaging> 

<dependencies> 
    <dependency> 
     <groupId>org.eclipse.persistence</groupId> 
     <artifactId>eclipselink</artifactId> 
     <version>2.5.0</version> 
    </dependency> 

    <dependency> 
     <groupId>org.jboss.resteasy</groupId> 
     <artifactId>resteasy-jaxrs</artifactId> 
     <version>3.0.4.Final</version> 
     <scope>provided</scope> 
    </dependency> 

    <dependency> 
     <groupId>javax.validation</groupId> 
     <artifactId>validation-api</artifactId> 
     <version>1.0.0.GA</version> 
    </dependency> 

    <dependency> 
     <groupId>com.mysema.querydsl</groupId> 
     <artifactId>querydsl-apt</artifactId> 
     <version>3.0.0</version> 
     <scope>provided</scope> 
    </dependency> 

    <dependency> 
     <groupId>com.mysema.querydsl</groupId> 
     <artifactId>querydsl-jpa</artifactId> 
     <version>3.0.0</version> 
    </dependency> 

    <dependency> 
     <groupId>javax.ejb</groupId> 
     <artifactId>javax.ejb-api</artifactId> 
     <version>3.2</version> 
     <scope>provided</scope> 
    </dependency> 

    <dependency> 
     <groupId>javax.faces</groupId> 
     <artifactId>javax.faces-api</artifactId> 
     <version>2.2</version> 
    </dependency> 


</dependencies> 

<build> 
    <plugins> 
     <plugin> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <version>2.3.2</version> 
      <configuration> 
       <source>1.6</source> 
       <target>1.6</target> 
      </configuration> 
     </plugin> 

     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-war-plugin</artifactId> 
      <version>2.3</version> 
      <configuration> 
       <failOnMissingWebXml>false</failOnMissingWebXml> 
      </configuration> 
     </plugin> 

     <plugin> 
      <groupId>com.mysema.maven</groupId> 
      <artifactId>apt-maven-plugin</artifactId> 
      <version>1.0.9</version> 
      <executions> 
       <execution> 
        <goals> 
         <goal>process</goal> 
        </goals> 
        <configuration> 
         <outputDirectory>target/generated-sources/java</outputDirectory> 
         <processor>com.mysema.query.apt.jpa.JPAAnnotationProcessor</processor> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 
    </plugins> 
</build> 

我創建了一個數據訪問類如下

@RequestScoped 
public class AddressDao extends BaseDao<Address, QAddress>{ 
} 

以下是我的資源文件。

@Path("hello") 
@RequestScoped 
@Stateless 
public class StructureResource { 

    @Inject 
    AddressDao addressDao; 

    @GET 
    public Response getList(){ 
     Address address = addressDao.get(1L); 
     return Response.ok().build(); 
    } 
} 

當我部署我得到以下錯誤。

Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type AddressDao with qualifiers @Default 
    at injection point [BackedAnnotatedField] @Inject  com.sms.modules.identity.boundary.StructureResource.addressDao 

請讓我知道我缺少的東西是什麼。

回答

0

是否創建文件beans.xml in resources您的maven項目的目錄?它是CDI規範所要求的,用於標記AS容器將在其中查找CDI bean的罐子。

+0

是的,這是問題。它的工作現在。謝謝.. beans.xml需要在META-INF下創建... –