Spring 将弹簧组件注入Jersey 2.22.1时出现不满足的Pendency异常

Spring 将弹簧组件注入Jersey 2.22.1时出现不满足的Pendency异常,spring,spring-boot,jersey-2.0,weblogic12c,spring-web,Spring,Spring Boot,Jersey 2.0,Weblogic12c,Spring Web,使用的技术: 弹簧护套4.2.4-释放 Jersey 2.x(春季启动版) 部署在Weblogic 12.1.3上 我遇到了org.glassfish.hk2.api.unsatifiedpendencyException:当我尝试注入Spring管理的资源时,在注入者错误处没有可供注入的对象 pom.xml <parent> <artifactId>sl-locates-ui-appsrv</artifactId> <groupId&g

使用的技术: 弹簧护套4.2.4-释放 Jersey 2.x(春季启动版) 部署在Weblogic 12.1.3上

我遇到了org.glassfish.hk2.api.unsatifiedpendencyException:当我尝试注入Spring管理的资源时,在注入者错误处没有可供注入的对象

pom.xml

<parent>
    <artifactId>sl-locates-ui-appsrv</artifactId>
    <groupId>com.db.sl</groupId>
    <version>0.0.0-SNAPSHOT</version>
</parent>

<properties>
    <start-class>com.db.sl.config.Application</start-class>
</properties>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.6</version>
            <configuration>
                <failOnMissingWebXml>false</failOnMissingWebXml>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <source>${jdk.version}</source>
                <target>${jdk.version}</target>
            </configuration>
        </plugin>
    </plugins>
</build>

<dependencies>

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.1.0</version>
    </dependency>


    <!-- Phoenix Specific -->
    <dependency>
        <groupId>com.db.sl</groupId>
        <artifactId>sl-locates-ftp-core</artifactId>
        <version>${sl-locates-ftp-core.version}</version>
        <exclusions>
            <exclusion>
                <artifactId>servlet-api</artifactId>
                <groupId>javax.servlet</groupId>
            </exclusion>
        </exclusions>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>com.db.gef</groupId>
        <artifactId>SLUtils</artifactId>
        <version>${slutils.version}</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>com.sybase</groupId>
        <artifactId>jconn4</artifactId>
        <version>${jconn4.version}</version>
        <type>jar</type>
        <scope>provided</scope>
    </dependency>

    <!-- Spring -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter</artifactId>
        <exclusions>
            <exclusion>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-tomcat</artifactId>
            </exclusion>
        </exclusions>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-jdbc</artifactId>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-jersey</artifactId>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
    </dependency>

</dependencies>
Spring的Config类

@Configuration
@EnableAutoConfiguration
@ComponentScan("com.db.sl")
public class SpringConfiguration {

@Bean
@Inject
LocatesDAO createLoactesDAO(DataSource dataSource) {
    System.out.println("DataSource: " + dataSource.toString());
    return new LocatesDAOImpl(dataSource);
}
}
最后是发生错误的类

@Named
@Path("/locates")
public class LocatesRestEndPoint {

@Inject
private LocatesRequestService requestsService;

@GET
@Path("/requests/{customerKey}")
@Produces(MediaType.APPLICATION_JSON)
public LocatesWebResponse getFileRequestsWith(@PathParam("customerId") String customerId) throws Exception {
    log.info("Facilitating request for Locates File Requests with customer key " + customerId);

    return requestsService.getLocateRequests(customerId);
}
}
我一直在将这个项目部署到tomcat上,但我们的工作环境要求使用weblogic。该项目在tomcat上运行,但在weblogic上,我甚至没有在部署时显示spring横幅。我已经检查了我能找到的所有日志,没有发现其他错误情况。我的堆栈跟踪是:

####<Jan 25, 2016 5:09:25 PM EST> <Error> <HTTP> <USRDUDT808849>     <AdminServer> <[ACTIVE] ExecuteThread: '4' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1453759765485> <BEA-101017> <[ServletContext@2070365887[app:sl-locates-ui-appsrv-rest-0.0.0-SNAPSHOT module:sl-locates-ui-appsrv-rest-0.0.0-SNAPSHOT.war path:null spec-version:3.0], request: weblogic.servlet.internal.ServletRequestImpl@15ba67aa[
GET /sl-locates-ui-appsrv-rest-0.0.0-SNAPSHOT/rest/locates/requests/with-date/2010-02-03 HTTP/1.1
Accept: text/html, application/xhtml+xml, */*
Accept-Language: en-US
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko
Accept-Encoding: gzip, deflate
DNT: 1
Connection: Keep-Alive

]] Root cause of ServletException.
A MultiException has 3 exceptions.  They are:
1. org.glassfish.hk2.api.UnsatisfiedDependencyException: There was no object available for injection at Injectee(requiredType=LocatesRequestService,parent=LocatesRestEndPoint,qualifiers={}),position=-1,optional=false,self=false,unqualified=null,1669020655)
2. java.lang.IllegalArgumentException: While attempting to resolve the dependencies of com.db.sl.appsrv.endpoints.LocatesRestEndPoint errors were found
3. java.lang.IllegalStateException: Unable to perform operation: resolve on com.db.sl.appsrv.endpoints.LocatesRestEndPoint

at org.jvnet.hk2.internal.Collector.throwIfErrors(Collector.java:88)
at org.jvnet.hk2.internal.ClazzCreator.resolveAllDependencies(ClazzCreator.java:269)
at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:413)
at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:456)
at org.glassfish.jersey.process.internal.RequestScope.findOrCreate(RequestScope.java:158)
at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2488)
at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:629)
at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:614)
at org.glassfish.jersey.internal.inject.Injections.getOrCreate(Injections.java:173)
at org.glassfish.jersey.server.model.MethodHandler$ClassBasedMethodHandler.getInstance(MethodHandler.java:185)
at org.glassfish.jersey.server.internal.routing.PushMethodHandlerRouter.apply(PushMethodHandlerRouter.java:103)
at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:128)
at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:131)
at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:131)
at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:131)
at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:131)
at org.glassfish.jersey.server.internal.routing.RoutingStage.apply(RoutingStage.java:110)
at org.glassfish.jersey.server.internal.routing.RoutingStage.apply(RoutingStage.java:65)
at org.glassfish.jersey.process.internal.Stages.process(Stages.java:197)
at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:250)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:318)
at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:236)
at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1010)
at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:373)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:382)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:345)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:220)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:280)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:254)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:136)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:346)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:243)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3432)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3402)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:57)
at weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2285)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2201)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2179)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1572)
at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:255)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:311)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:263)

######对我来说似乎很奇怪,您的所有依赖项都是
提供的
所有依赖项都将在部署服务器的类路径上可用。我对maven还是一个新手,但我的印象是这将使战争规模保持较小。它还可以防止出现大量的类定义异常。这方面运气好吗?此外,weblogic还存在一些问题,它在提供文件方面“很有用”,但通常您希望将类依赖项与war捆绑在一起。
@Configuration
@EnableAutoConfiguration
@ComponentScan("com.db.sl")
public class SpringConfiguration {

@Bean
@Inject
LocatesDAO createLoactesDAO(DataSource dataSource) {
    System.out.println("DataSource: " + dataSource.toString());
    return new LocatesDAOImpl(dataSource);
}
}
@Named
@Path("/locates")
public class LocatesRestEndPoint {

@Inject
private LocatesRequestService requestsService;

@GET
@Path("/requests/{customerKey}")
@Produces(MediaType.APPLICATION_JSON)
public LocatesWebResponse getFileRequestsWith(@PathParam("customerId") String customerId) throws Exception {
    log.info("Facilitating request for Locates File Requests with customer key " + customerId);

    return requestsService.getLocateRequests(customerId);
}
}
####<Jan 25, 2016 5:09:25 PM EST> <Error> <HTTP> <USRDUDT808849>     <AdminServer> <[ACTIVE] ExecuteThread: '4' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1453759765485> <BEA-101017> <[ServletContext@2070365887[app:sl-locates-ui-appsrv-rest-0.0.0-SNAPSHOT module:sl-locates-ui-appsrv-rest-0.0.0-SNAPSHOT.war path:null spec-version:3.0], request: weblogic.servlet.internal.ServletRequestImpl@15ba67aa[
GET /sl-locates-ui-appsrv-rest-0.0.0-SNAPSHOT/rest/locates/requests/with-date/2010-02-03 HTTP/1.1
Accept: text/html, application/xhtml+xml, */*
Accept-Language: en-US
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko
Accept-Encoding: gzip, deflate
DNT: 1
Connection: Keep-Alive

]] Root cause of ServletException.
A MultiException has 3 exceptions.  They are:
1. org.glassfish.hk2.api.UnsatisfiedDependencyException: There was no object available for injection at Injectee(requiredType=LocatesRequestService,parent=LocatesRestEndPoint,qualifiers={}),position=-1,optional=false,self=false,unqualified=null,1669020655)
2. java.lang.IllegalArgumentException: While attempting to resolve the dependencies of com.db.sl.appsrv.endpoints.LocatesRestEndPoint errors were found
3. java.lang.IllegalStateException: Unable to perform operation: resolve on com.db.sl.appsrv.endpoints.LocatesRestEndPoint

at org.jvnet.hk2.internal.Collector.throwIfErrors(Collector.java:88)
at org.jvnet.hk2.internal.ClazzCreator.resolveAllDependencies(ClazzCreator.java:269)
at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:413)
at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:456)
at org.glassfish.jersey.process.internal.RequestScope.findOrCreate(RequestScope.java:158)
at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2488)
at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:629)
at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:614)
at org.glassfish.jersey.internal.inject.Injections.getOrCreate(Injections.java:173)
at org.glassfish.jersey.server.model.MethodHandler$ClassBasedMethodHandler.getInstance(MethodHandler.java:185)
at org.glassfish.jersey.server.internal.routing.PushMethodHandlerRouter.apply(PushMethodHandlerRouter.java:103)
at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:128)
at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:131)
at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:131)
at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:131)
at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:131)
at org.glassfish.jersey.server.internal.routing.RoutingStage.apply(RoutingStage.java:110)
at org.glassfish.jersey.server.internal.routing.RoutingStage.apply(RoutingStage.java:65)
at org.glassfish.jersey.process.internal.Stages.process(Stages.java:197)
at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:250)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:318)
at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:236)
at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1010)
at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:373)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:382)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:345)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:220)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:280)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:254)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:136)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:346)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:243)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3432)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3402)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:57)
at weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2285)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2201)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2179)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1572)
at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:255)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:311)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:263)