Java Jersey Guice集成异常

Java Jersey Guice集成异常,java,web-services,maven,dependency-injection,guice,Java,Web Services,Maven,Dependency Injection,Guice,我正在努力让Guice参加我的运动衫/灰熊课程。我从控制台Java应用程序开始,添加了Guice,让我的注入和我的域对象一样工作。然后我继续通过Jersey/Grizzly添加Web服务。从我的编码风格可以看出,我有C#的背景。所以我确信我的一些奋斗是学习Javas的做事方式 我想要的是,我的非webservices类可以被注入webservices处理程序,这样它们就可以使用我构建的功能 在下面的类中,我有一个数据库实例处理程序要注入到webservices类中: @Path("/option

我正在努力让Guice参加我的运动衫/灰熊课程。我从控制台Java应用程序开始,添加了Guice,让我的注入和我的域对象一样工作。然后我继续通过Jersey/Grizzly添加Web服务。从我的编码风格可以看出,我有C#的背景。所以我确信我的一些奋斗是学习Javas的做事方式

我想要的是,我的非webservices类可以被注入webservices处理程序,这样它们就可以使用我构建的功能

在下面的类中,我有一个数据库实例处理程序要注入到webservices类中:

@Path("/options")
public class OptionsServices {

    private IDatabaseService dbService;

    @Inject
    public void setService(IDatabaseService svc){
        this.dbService = svc;
    }


    @GET
    @Path("{symbol}")
    @Produces(MediaType.APPLICATION_JSON)
    public Quote getOptionQuote(@PathParam("symbol") String symbol) {
        // do stuff
    }
}
我尝试添加GuiceBridge并将其绑定到ResourceConfig类的扩展中。但是,无论我使用什么版本,当我试图初始化Web服务时,我都会遇到一些关于缺少属性的异常。只需从我的pom.xml中删除GuiceBridge即可删除异常。这似乎是它的版本兼容性问题,但我不知道什么库的哪个版本

Exception in thread "main" java.lang.NoSuchMethodError: org.glassfish.hk2.utilities.general.GeneralUtilities.getSystemProperty(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
        at org.jvnet.hk2.internal.ServiceLocatorImpl.<clinit>(ServiceLocatorImpl.java:122)
        at org.jvnet.hk2.external.generator.ServiceLocatorGeneratorImpl.initialize(ServiceLocatorGeneratorImpl.java:66)
        at org.jvnet.hk2.external.generator.ServiceLocatorGeneratorImpl.create(ServiceLocatorGeneratorImpl.java:98)
        at org.glassfish.hk2.internal.ServiceLocatorFactoryImpl.internalCreate(ServiceLocatorFactoryImpl.java:312)
        at org.glassfish.hk2.internal.ServiceLocatorFactoryImpl.create(ServiceLocatorFactoryImpl.java:268)
        at org.glassfish.jersey.internal.inject.Injections._createLocator(Injections.java:138)
        at org.glassfish.jersey.internal.inject.Injections.createLocator(Injections.java:123)
        at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:308)
        at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:289)
        at org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpContainer.<init>(GrizzlyHttpContainer.java:334)
        at org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory.createHttpServer(GrizzlyHttpServerFactory.java:122)
        at Application.Server.WebServer.startServer(WebServer.java:40)
        at Application.Server.WebServer.Start(WebServer.java:45)
        at Application.Startup.run(Startup.java:68)
        at Application.Startup.main(Startup.java:87)
线程“main”java.lang.NoSuchMethodError中的异常:org.glassfish.hk2.utilities.general.GeneralUtilities.getSystemProperty(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String; 位于org.jvnet.hk2.internal.ServiceLocatorImpl.(ServiceLocatorImpl.java:122) 位于org.jvnet.hk2.external.generator.ServiceLocatorGeneratorImpl.initialize(ServiceLocatorGeneratorImpl.java:66) 位于org.jvnet.hk2.external.generator.ServiceLocatorGeneratorImpl.create(ServiceLocatorGeneratorImpl.java:98) 位于org.glassfish.hk2.internal.ServiceLocatorFactoryImpl.internalCreate(ServiceLocatorFactoryImpl.java:312) 位于org.glassfish.hk2.internal.ServiceLocatorFactoryImpl.create(ServiceLocatorFactoryImpl.java:268) 位于org.glassfish.jersey.internal.injection.Injections.\u createLocator(Injections.java:138) 位于org.glassfish.jersey.internal.injection.Injections.createLocator(Injections.java:123) 位于org.glassfish.jersey.server.ApplicationHandler.(ApplicationHandler.java:308) 位于org.glassfish.jersey.server.ApplicationHandler.(ApplicationHandler.java:289) 位于org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpContainer.(GrizzlyHttpContainer.java:334) 位于org.glassfish.jersey.grizzly2.httpserver.grizzlyhttpserver.createHttpServer(grizzlyhttpserver.java:122) 位于Application.Server.WebServer.startServer(WebServer.java:40) 位于Application.Server.WebServer.Start(WebServer.java:45) 运行(Startup.java:68) 位于Application.Startup.main(Startup.java:87) 还有我的pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>tatmancapital</groupId>
    <artifactId>ServerConsole</artifactId>
    <version>R1</version>

    <properties>
        <jersey.version>2.17</jersey.version>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.glassfish.jersey</groupId>
                <artifactId>jersey-bom</artifactId>
                <version>${jersey.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <!-- https://mvnrepository.com/artifact/com.google.inject/guice -->
        <dependency>
            <groupId>com.google.inject</groupId>
            <artifactId>guice</artifactId>
            <version>4.1.0</version>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.6</version>
        </dependency>

        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.15</version>
            <exclusions>
                <exclusion>
                    <groupId>com.sun.jmx</groupId>
                    <artifactId>jmxri</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.sun.jdmk</groupId>
                    <artifactId>jmxtools</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>javax.jms</groupId>
                    <artifactId>jms</artifactId>
                </exclusion>
            </exclusions>           
        </dependency>       

        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
            <version>1.3</version>
        </dependency>

        <dependency>
            <groupId>commons-httpclient</groupId>
            <artifactId>commons-httpclient</artifactId>
            <version>3.1</version>
        </dependency>

        <dependency>
            <groupId>com.thoughtworks.xstream</groupId>
            <artifactId>xstream</artifactId>
            <version>1.4.9</version>
        </dependency>

        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
            <version>2.4</version>
        </dependency>

        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <version>1.0.4</version>
        </dependency>

        <dependency>
            <groupId>org.glassfish.jersey.containers</groupId>
            <artifactId>jersey-container-grizzly2-http</artifactId>
        </dependency>

        <dependency>
            <groupId>org.glassfish.jersey.media</groupId>
            <artifactId>jersey-media-moxy</artifactId>
        </dependency>


        <dependency>
            <groupId>org.glassfish.hk2</groupId>
            <artifactId>guice-bridge</artifactId>
            <version>2.5.0-b32</version>
        </dependency>       

        <dependency>
            <groupId>commons-httpclient-ssl-contrib</groupId>
            <artifactId>commons-httpclient-ssl-contrib</artifactId>
            <version>3.1</version>
           <scope>system</scope>
           <systemPath>${project.basedir}/libs/commons-httpclient-contrib-ssl-3.1.jar</systemPath>
        </dependency>

        <dependency>
           <groupId>etrade</groupId>
           <artifactId>com.etrade.accounts</artifactId>
           <version>1.0</version>
           <scope>system</scope>
           <systemPath>${project.basedir}/libs/etws-accounts-sdk-1.0.jar</systemPath>
        </dependency>

        <dependency>
           <groupId>etrade</groupId>
           <artifactId>com.etrade.order</artifactId>
           <version>1.0</version>
           <scope>system</scope>
           <systemPath>${project.basedir}/libs/etws-order-sdk-1.0.jar</systemPath>
        </dependency>

        <dependency>
           <groupId>etrade</groupId>
           <artifactId>com.etrade.oauth</artifactId>
           <version>1.0</version>
           <scope>system</scope>
           <systemPath>${project.basedir}/libs/etws-oauth-sdk-1.0.jar</systemPath>
        </dependency>

        <dependency>
           <groupId>etrade</groupId>
           <artifactId>com.etrade.markets</artifactId>
           <version>1.0</version>
           <scope>system</scope>
           <systemPath>${project.basedir}/libs/etws-market-sdk-1.0.jar</systemPath>
        </dependency>

        <dependency>
           <groupId>etrade</groupId>
           <artifactId>com.etrade.common</artifactId>
           <version>1.0</version>
           <scope>system</scope>
           <systemPath>${project.basedir}/libs/etws-common-connections-1.0.jar</systemPath>
        </dependency>               

    </dependencies>

    <build>
      <plugins>     
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>3.0.0</version>
            <configuration>
                <archive>
                  <manifest>            
                    <mainClass>Application.Startup</mainClass>                  
                  </manifest>
                </archive>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
                <appendAssemblyId>false</appendAssemblyId>
                <finalName>ServerConsole-V1</finalName>
            </configuration>
            <executions>
                <execution>
                    <id>make-assembly</id> <!-- this is used for inheritance merges -->
                    <phase>package</phase> <!-- bind to the packaging phase -->
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>       
      </plugins>
    </build>
</project>

4.0.0
塔曼资本
服务器控制台
R1
2.17
org.glassfish.jersey
针织面料
${jersey.version}
聚甲醛
进口
com.google.inject
圭斯
4.1.0
mysql
mysql连接器java
5.1.6
log4j
log4j
1.2.15
com.sun.jmx
jmxri
com.sun.jdmk
jmxtools
javax.jms
jms
通用编解码器
通用编解码器
1.3
commons httpclient
commons httpclient
3.1
com.thoughtworks.xstream
xstream
1.4.9
公地郎
公地郎
2.4
公用记录
公用记录
1.0.4
org.glassfish.jersey.containers
jersey-container-grizzly2-http
org.glassfish.jersey.media
泽西媒体公司
org.glassfish.hk2
圭斯桥
2.5.0-b32
commons httpclient ssl contrib
commons httpclient ssl contrib
3.1
系统
${project.basedir}/libs/commons-httpclient-contrib-ssl-3.1.jar
etrade
com.etrade.accounts
1
系统
${project.basedir}/libs/etws-accounts-sdk-1.0.jar
etrade
com.etrade.order
1
系统
${project.basedir}/libs/etws-order-sdk-1.0.jar
etrade
com.etrade.oauth
1
系统
${project.basedir}/libs/etws-oauth-sdk-1.0.jar
etrade
com.etrade.markets
1
系统
${project.basedir}/libs/etws-market-sdk-1.0.jar
etrade
com.etrade.common
1
系统
${project.basedir}/libs/etws-common-connections-1.0.jar
maven汇编插件
3.0.0
应用程序启动
带有依赖项的jar
假的
服务器控制台-V1
组装
包裹
单一的
很抱歉,我无法用更多的语言解释这个问题