简体   繁体   English

Maven和Spring Boot的Groovy依赖问题

[英]Groovy Dependency Issue with Maven and Spring Boot

I have a Spring Boot application which includes a number of other libraries. 我有一个Spring Boot应用程序,其中包括许多其他库。 It compiles fine ( mvn clean package ), but when I try to run the built server I get the following error: 它可以正常编译( mvn clean package ),但是当我尝试运行内置服务器时,出现以下错误:

java.lang.ExceptionInInitializerError: null
    at org.springframework.beans.factory.groovy.GroovyBeanDefinitionReader.<init>(GroovyBeanDefinitionReader.java:150) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE]
    at org.springframework.boot.BeanDefinitionLoader.<init>(BeanDefinitionLoader.java:84) ~[spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE]
    at org.springframework.boot.SpringApplication.createBeanDefinitionLoader(SpringApplication.java:684) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE]
    at org.springframework.boot.SpringApplication.load(SpringApplication.java:624) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE]
    at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:355) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:301) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE]
    at myproject.graphutils.server.GraphUtilsServer.main(GraphUtilsServer.java:9) [classes!/:1.0-SNAPSHOT]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
    at java.base/java.lang.reflect.Method.invoke(Method.java:564) ~[na:na]
    at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [graph-utils-server-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
    at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [graph-utils-server-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
    at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [graph-utils-server-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
    at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) [graph-utils-server-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
Caused by: groovy.lang.GroovyRuntimeException: Conflicting module versions. Module [groovy-xml is loaded in version 2.4.11 and you are trying to load version 2.4.13
    at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl$DefaultModuleListener.onModule(MetaClassRegistryImpl.java:513) ~[data-to-graph-mapper-1.0-SNAPSHOT.jar!/:na]
    at org.codehaus.groovy.runtime.m12n.ExtensionModuleScanner.scanExtensionModuleFromProperties(ExtensionModuleScanner.java:80) ~[data-to-graph-mapper-1.0-SNAPSHOT.jar!/:na]
    at org.codehaus.groovy.runtime.m12n.ExtensionModuleScanner.scanExtensionModuleFromMetaInf(ExtensionModuleScanner.java:74) ~[data-to-graph-mapper-1.0-SNAPSHOT.jar!/:na]
    at org.codehaus.groovy.runtime.m12n.ExtensionModuleScanner.scanClasspathModules(ExtensionModuleScanner.java:56) ~[data-to-graph-mapper-1.0-SNAPSHOT.jar!/:na]
    at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.<init>(MetaClassRegistryImpl.java:113) ~[data-to-graph-mapper-1.0-SNAPSHOT.jar!/:na]
    at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.<init>(MetaClassRegistryImpl.java:74) ~[data-to-graph-mapper-1.0-SNAPSHOT.jar!/:na]
    at groovy.lang.GroovySystem.<clinit>(GroovySystem.java:36) ~[data-to-graph-mapper-1.0-SNAPSHOT.jar!/:na]
    ... 17 common frames omitted

I've tried forcing the correct dependency version of all the Groovy related modules, but that hasn't helped. 我尝试过强制所有与Groovy相关的模块的正确依赖版本,但这并没有帮助。 Here's my POM file (with the forced versions): 这是我的POM文件(带有强制版本):

<?xml version="1.0" encoding="UTF-8"?>
<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>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.10.RELEASE</version>
    </parent>

    <groupId>myproject</groupId>
    <artifactId>graph-utils-server</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>

    <dependencies>
        <dependency>
            <groupId>myproject</groupId>
            <artifactId>graph-utils</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>

        <dependency>
            <groupId>myproject</groupId>
            <artifactId>data-to-graph-mapper</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>

        <!-- Spring Boot -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.6</version>
        </dependency>

        <!-- AWS -->
        <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-java-sdk-s3</artifactId>
            <version>1.11.276</version>
        </dependency>

        <!-- Force versions -->
        <dependency>
            <groupId>org.apache.tinkerpop</groupId>
            <artifactId>tinkergraph-gremlin</artifactId>
            <version>3.3.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tinkerpop</groupId>
            <artifactId>gremlin-groovy</artifactId>
            <version>3.3.1</version>
        </dependency>
        <dependency>
            <groupId>org.codehaus.groovy</groupId>
            <artifactId>groovy</artifactId>
            <version>2.4.13</version>
            <classifier>indy</classifier>
        </dependency>
        <dependency>
            <groupId>org.codehaus.groovy</groupId>
            <artifactId>groovy-groovysh</artifactId>
            <version>2.4.13</version>
            <classifier>indy</classifier>
        </dependency>
        <dependency>
            <groupId>org.codehaus.groovy</groupId>
            <artifactId>groovy-json</artifactId>
            <version>2.4.13</version>
            <classifier>indy</classifier>
        </dependency>
        <dependency>
            <groupId>org.codehaus.groovy</groupId>
            <artifactId>groovy-jsr223</artifactId>
            <version>2.4.13</version>
            <classifier>indy</classifier>
        </dependency>

    <!-- JanusGraph -->
        <dependency>
            <groupId>org.janusgraph</groupId>
            <artifactId>janusgraph-core</artifactId>
            <version>0.2.0</version>
        </dependency>
        <dependency>
            <groupId>org.janusgraph</groupId>
            <artifactId>janusgraph-hbase</artifactId>
            <version>0.2.0</version>
        </dependency>
        <dependency>
            <groupId>org.janusgraph</groupId>
            <artifactId>janusgraph-lucene</artifactId>
            <version>0.2.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.hbase</groupId>
            <artifactId>hbase-client</artifactId>
            <version>1.4.1</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>

And here's the Maven dependency tree: 这是Maven依赖树:

--- maven-dependency-plugin:2.10:tree (default-cli) @ graph-utils-server ---

myproject:graph-utils-server:jar:1.0-SNAPSHOT
+- myproject:graph-utils:jar:1.0-SNAPSHOT:compile
+- myproject:data-to-graph-mapper:jar:1.0-SNAPSHOT:compile
+- org.springframework.boot:spring-boot-starter-web:jar:1.5.10.RELEASE:compile
|  +- org.springframework.boot:spring-boot-starter:jar:1.5.10.RELEASE:compile
|  |  +- org.springframework.boot:spring-boot-starter-logging:jar:1.5.10.RELEASE:compile
|  |  |  +- org.slf4j:jul-to-slf4j:jar:1.7.25:compile
|  |  |  \- org.slf4j:log4j-over-slf4j:jar:1.7.25:compile
|  |  +- org.springframework:spring-core:jar:4.3.14.RELEASE:compile
|  |  \- org.yaml:snakeyaml:jar:1.17:compile
|  +- org.springframework.boot:spring-boot-starter-tomcat:jar:1.5.10.RELEASE:compile
|  |  +- org.apache.tomcat.embed:tomcat-embed-core:jar:8.5.27:compile
|  |  |  \- org.apache.tomcat:tomcat-annotations-api:jar:8.5.27:compile
|  |  +- org.apache.tomcat.embed:tomcat-embed-el:jar:8.5.27:compile
|  |  \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:8.5.27:compile
|  +- org.hibernate:hibernate-validator:jar:5.3.6.Final:compile
|  |  +- javax.validation:validation-api:jar:1.1.0.Final:compile
|  |  +- org.jboss.logging:jboss-logging:jar:3.3.1.Final:compile
|  |  \- com.fasterxml:classmate:jar:1.3.4:compile
|  +- com.fasterxml.jackson.core:jackson-databind:jar:2.8.10:compile
|  |  +- com.fasterxml.jackson.core:jackson-annotations:jar:2.8.0:compile
|  |  \- com.fasterxml.jackson.core:jackson-core:jar:2.8.10:compile
|  +- org.springframework:spring-web:jar:4.3.14.RELEASE:compile
|  |  +- org.springframework:spring-aop:jar:4.3.14.RELEASE:compile
|  |  +- org.springframework:spring-beans:jar:4.3.14.RELEASE:compile
|  |  \- org.springframework:spring-context:jar:4.3.14.RELEASE:compile
|  \- org.springframework:spring-webmvc:jar:4.3.14.RELEASE:compile
|     \- org.springframework:spring-expression:jar:4.3.14.RELEASE:compile
+- org.springframework.boot:spring-boot-devtools:jar:1.5.10.RELEASE:compile
|  +- org.springframework.boot:spring-boot:jar:1.5.10.RELEASE:compile
|  \- org.springframework.boot:spring-boot-autoconfigure:jar:1.5.10.RELEASE:compile
+- commons-io:commons-io:jar:2.6:compile
+- com.amazonaws:aws-java-sdk-s3:jar:1.11.276:compile
|  +- com.amazonaws:aws-java-sdk-kms:jar:1.11.276:compile
|  +- com.amazonaws:aws-java-sdk-core:jar:1.11.276:compile
|  |  +- org.apache.httpcomponents:httpclient:jar:4.5.5:compile
|  |  |  \- org.apache.httpcomponents:httpcore:jar:4.4.9:compile
|  |  +- software.amazon.ion:ion-java:jar:1.0.2:compile
|  |  +- com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:jar:2.8.10:compile
|  |  \- joda-time:joda-time:jar:2.9.9:compile
|  \- com.amazonaws:jmespath-java:jar:1.11.276:compile
+- org.apache.tinkerpop:tinkergraph-gremlin:jar:3.3.1:compile
|  +- org.apache.tinkerpop:gremlin-core:jar:3.3.1:compile
|  |  +- org.apache.tinkerpop:gremlin-shaded:jar:3.3.1:compile
|  |  +- org.javatuples:javatuples:jar:1.2:compile
|  |  +- com.jcabi:jcabi-manifests:jar:1.1:compile
|  |  |  \- com.jcabi:jcabi-log:jar:0.14:compile
|  |  +- com.squareup:javapoet:jar:1.8.0:compile
|  |  +- net.objecthunter:exp4j:jar:0.4.8:compile
|  |  \- org.slf4j:jcl-over-slf4j:jar:1.7.25:compile
|  \- org.apache.commons:commons-lang3:jar:3.3.1:compile
+- org.apache.tinkerpop:gremlin-groovy:jar:3.3.1:compile
|  +- org.apache.ivy:ivy:jar:2.3.0:compile
|  +- org.mindrot:jbcrypt:jar:0.4:compile
|  \- com.github.ben-manes.caffeine:caffeine:jar:2.3.5:compile
+- org.codehaus.groovy:groovy:jar:indy:2.4.13:compile
+- org.codehaus.groovy:groovy-groovysh:jar:indy:2.4.13:compile
|  +- org.codehaus.groovy:groovy:jar:2.4.13:compile
|  +- org.codehaus.groovy:groovy-console:jar:2.4.13:compile
|  |  +- org.codehaus.groovy:groovy-swing:jar:2.4.13:compile
|  |  \- org.codehaus.groovy:groovy-templates:jar:2.4.13:compile
|  |     \- org.codehaus.groovy:groovy-xml:jar:2.4.13:compile
|  \- jline:jline:jar:2.12:compile
+- org.codehaus.groovy:groovy-json:jar:indy:2.4.13:compile
+- org.codehaus.groovy:groovy-jsr223:jar:indy:2.4.13:compile
+- org.janusgraph:janusgraph-core:jar:0.2.0:compile
|  +- org.glassfish:javax.json:jar:1.0:compile
|  +- com.codahale.metrics:metrics-core:jar:3.0.1:compile
|  +- com.codahale.metrics:metrics-ganglia:jar:3.0.1:compile
|  |  \- info.ganglia.gmetric4j:gmetric4j:jar:1.0.3:compile
|  +- com.codahale.metrics:metrics-graphite:jar:3.0.1:compile
|  +- org.reflections:reflections:jar:0.9.9-RC1:compile
|  |  +- org.javassist:javassist:jar:3.21.0-GA:compile
|  |  \- dom4j:dom4j:jar:1.6.1:compile
|  |     \- xml-apis:xml-apis:jar:1.4.01:compile
|  +- org.locationtech.spatial4j:spatial4j:jar:0.6:compile
|  +- commons-collections:commons-collections:jar:3.2.2:compile
|  +- commons-configuration:commons-configuration:jar:1.10:compile
|  +- commons-codec:commons-codec:jar:1.10:compile
|  +- com.google.guava:guava:jar:18.0:compile
|  +- com.carrotsearch:hppc:jar:0.7.1:compile
|  +- com.github.stephenc.high-scale-lib:high-scale-lib:jar:1.1.4:compile
|  +- com.google.code.findbugs:jsr305:jar:3.0.0:compile
|  +- org.noggit:noggit:jar:0.6:compile
|  +- org.apache.commons:commons-text:jar:1.0:compile
|  \- org.slf4j:slf4j-api:jar:1.7.25:compile
+- org.janusgraph:janusgraph-hbase:jar:0.2.0:compile
|  \- ch.qos.logback:logback-classic:jar:1.1.11:compile
|     \- ch.qos.logback:logback-core:jar:1.1.11:compile
+- org.janusgraph:janusgraph-lucene:jar:0.2.0:compile
|  +- org.apache.lucene:lucene-core:jar:7.0.0:compile
|  +- org.apache.lucene:lucene-analyzers-common:jar:7.0.0:compile
|  +- org.apache.lucene:lucene-queryparser:jar:7.0.0:compile
|  |  +- org.apache.lucene:lucene-queries:jar:7.0.0:compile
|  |  \- org.apache.lucene:lucene-sandbox:jar:7.0.0:compile
|  +- org.apache.lucene:lucene-spatial:jar:7.0.0:compile
|  \- org.apache.lucene:lucene-spatial-extras:jar:7.0.0:compile
|     \- org.apache.lucene:lucene-spatial3d:jar:7.0.0:compile
\- org.apache.hbase:hbase-client:jar:1.4.1:compile
   +- org.apache.hbase:hbase-annotations:jar:1.4.1:compile
   |  +- com.github.stephenc.findbugs:findbugs-annotations:jar:1.3.9-1:compile
   |  +- log4j:log4j:jar:1.2.17:compile
   |  \- junit:junit:jar:4.12:compile
   |     \- org.hamcrest:hamcrest-core:jar:1.3:compile
   +- org.apache.hbase:hbase-common:jar:1.4.1:compile
   |  +- org.mortbay.jetty:jetty-util:jar:6.1.26:compile
   |  \- org.apache.avro:avro:jar:1.7.7:compile
   |     +- com.thoughtworks.paranamer:paranamer:jar:2.3:compile
   |     \- org.xerial.snappy:snappy-java:jar:1.0.5:compile
   +- org.apache.hbase:hbase-hadoop-compat:jar:1.4.1:compile
   |  +- org.apache.commons:commons-math:jar:2.2:compile
   |  \- org.apache.hbase:hbase-metrics-api:jar:1.4.1:compile
   +- org.apache.hbase:hbase-hadoop2-compat:jar:1.4.1:compile
   |  \- org.apache.hbase:hbase-metrics:jar:1.4.1:compile
   |     \- io.dropwizard.metrics:metrics-core:jar:3.1.5:compile
   +- org.apache.hbase:hbase-protocol:jar:1.4.1:compile
   +- commons-lang:commons-lang:jar:2.6:compile
   +- commons-logging:commons-logging:jar:1.2:compile
   +- com.google.protobuf:protobuf-java:jar:2.5.0:compile
   +- io.netty:netty-all:jar:4.1.8.Final:compile
   +- org.apache.zookeeper:zookeeper:jar:3.4.10:compile
   |  \- org.slf4j:slf4j-log4j12:jar:1.7.25:compile
   +- org.apache.htrace:htrace-core:jar:3.1.0-incubating:compile
   +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.13:compile
   |  \- org.codehaus.jackson:jackson-core-asl:jar:1.9.13:compile
   +- org.jruby.jcodings:jcodings:jar:1.0.8:compile
   +- org.jruby.joni:joni:jar:2.1.2:compile
   +- com.yammer.metrics:metrics-core:jar:2.2.0:compile
   +- org.apache.hadoop:hadoop-auth:jar:2.7.4:compile
   |  +- org.apache.directory.server:apacheds-kerberos-codec:jar:2.0.0-M15:compile
   |  |  +- org.apache.directory.server:apacheds-i18n:jar:2.0.0-M15:compile
   |  |  +- org.apache.directory.api:api-asn1-api:jar:1.0.0-M20:compile
   |  |  \- org.apache.directory.api:api-util:jar:1.0.0-M20:compile
   |  \- org.apache.curator:curator-framework:jar:2.7.1:compile
   +- org.apache.hadoop:hadoop-common:jar:2.7.4:compile
   |  +- org.apache.hadoop:hadoop-annotations:jar:2.7.4:compile
   |  |  \- jdk.tools:jdk.tools:jar:1.8:system
   |  +- commons-cli:commons-cli:jar:1.2:compile
   |  +- org.apache.commons:commons-math3:jar:3.1.1:compile
   |  +- xmlenc:xmlenc:jar:0.52:compile
   |  +- commons-httpclient:commons-httpclient:jar:3.1:compile
   |  +- commons-net:commons-net:jar:3.1:compile
   |  +- org.mortbay.jetty:jetty-sslengine:jar:6.1.26:compile
   |  +- com.google.code.gson:gson:jar:2.8.2:compile
   |  +- com.jcraft:jsch:jar:0.1.54:compile
   |  +- org.apache.curator:curator-client:jar:2.7.1:compile
   |  +- org.apache.curator:curator-recipes:jar:2.7.1:compile
   |  \- org.apache.commons:commons-compress:jar:1.4.1:compile
   |     \- org.tukaani:xz:jar:1.0:compile
   \- org.apache.hadoop:hadoop-mapreduce-client-core:jar:2.7.4:compile
      +- org.apache.hadoop:hadoop-yarn-common:jar:2.7.4:compile
      |  +- org.apache.hadoop:hadoop-yarn-api:jar:2.7.4:compile
      |  \- javax.xml.bind:jaxb-api:jar:2.2.2:compile
      |     +- javax.xml.stream:stax-api:jar:1.0-2:compile
      |     \- javax.activation:activation:jar:1.1:compile
      \- io.netty:netty:jar:3.6.2.Final:compile

Any ideas how to resolve this issue? 任何想法如何解决这个问题?

I always start my Spring Boot Groovy projects via Spring Initializer to make sure I have a good starting point. 我总是通过Spring Initializer启动Spring Boot Groovy项目,以确保我有一个很好的起点。 One thing you are missing is GMaven which I think is necessary to use Groovy with Maven here. 您缺少的一件事是GMaven,我认为在此处将Groovy与Maven一起使用是必需的。

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
        <plugin>
            <groupId>org.codehaus.gmavenplus</groupId>
            <artifactId>gmavenplus-plugin</artifactId>
            <version>1.5</version>
            <executions>
                <execution>
                    <goals>
                        <goal>addSources</goal>
                        <goal>addTestSources</goal>
                        <goal>generateStubs</goal>
                        <goal>compile</goal>
                        <goal>testGenerateStubs</goal>
                        <goal>testCompile</goal>
                        <goal>removeStubs</goal>
                        <goal>removeTestStubs</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

Haven't had time to validate but that's the first thing I see missing. 没时间去验证,但这是我发现的第一件事。 If that does not help, go to the spring initializer and generate a project and use it as a template. 如果那没有帮助,请转到spring初始化程序并生成一个项目并将其用作模板。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM