如何强制依赖项包含具有特定版本号的工件

如何强制依赖项包含具有特定版本号的工件

本文介绍了如何强制依赖项包含具有特定版本号的工件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试使用Maven构建GWT项目时出现此错误:

I get this error when trying to build GWT project with maven:

我发现gwt-user 2.6.0是通过com.google.gwt.eventbinder下载的.如何使用gwt-user 2.7.0而不是2.6.0强制com.google.gwt.eventbinder?

As I found out gwt-user 2.6.0 is downloaded with com.google.gwt.eventbinder.How I can force com.google.gwt.eventbinder using gwt-user 2.7.0 instead 2.6.0?

奇怪的是,该构建在我执行"git pull"之前就起作用了.

The strange thing is that the build worked before I did 'git pull'.

这是我的pom.xml

Here is my pom.xml

<?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>

<groupId>com.prognoz.ra.okhs</groupId>
<artifactId>gwtclient</artifactId>
<version>0.3.1-SNAPSHOT</version>

<packaging>war</packaging>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <gwt.version>2.7.0</gwt.version>
    <maven.version>3.0.5</maven.version>
    <jdk.version>1.7</jdk.version>
    <version.org.codehaus.mojo.gwt.maven.plugin>2.7.0</version.org.codehaus.mojo.gwt.maven.plugin>
    <webappDirectory>war</webappDirectory>
    <maven.build.timestamp.format>yyyy-MM-dd HH:mm</maven.build.timestamp.format>
    <skipTests>true</skipTests>
</properties>

<prerequisites>
    <maven>${maven.version}</maven>
</prerequisites>

<dependencies>
    <dependency>
        <groupId>org.moxieapps.gwt</groupId>
        <artifactId>highcharts</artifactId>
        <version>1.7.0</version>
        <scope>system</scope>
        <systemPath>${basedir}/src/main/webapp/WEB-INF/lib/highcharts-1.7.0.jar</systemPath>
    </dependency>

    <dependency>
        <groupId>com.prognoz.ra.dbutil</groupId>
        <artifactId>dbutil</artifactId>
        <scope>system</scope>
        <version>1.0.1-SNAPSHOT</version>
        <systemPath>${basedir}/out/artifacts/dbutil_jar/dbutil.jar</systemPath>
    </dependency>

    <dependency>
        <groupId>com.liferay.org.apache.commons.fileupload</groupId>
        <artifactId>com.liferay.org.apache.commons.fileupload</artifactId>
        <version>6.2.0.1</version>
    </dependency>

    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-io</artifactId>
        <version>1.3.2</version>
    </dependency>

    <dependency>
        <groupId>com.google.gwt</groupId>
        <version>${gwt.version}</version>
        <artifactId>gwt-servlet</artifactId>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jsp-api</artifactId>
        <version>2.0</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>18.0</version>
    </dependency>
    <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava-gwt</artifactId>
        <version>18.0</version>
    </dependency>
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.17</version>
    </dependency>

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

    <dependency>
        <groupId>com.google.gwt.eventbinder</groupId>
        <artifactId>eventbinder</artifactId>
        <version>1.1.0</version>
    </dependency>
</dependencies>

<build>
    <resources>
        <resource>
            <directory>${basedir}/src/main/java</directory>
            <includes>
                <include>**/*.properties</include>
            </includes>
        </resource>
    </resources>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>gwt-maven-plugin</artifactId>
            <version>${version.org.codehaus.mojo.gwt.maven.plugin}</version>
            <executions>
                <execution>
                    <goals>
                        <goal>compile</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
              <compileReport>true</compileReport>
              <logLevel>INFO</logLevel>
              <copyWebapp>true</copyWebapp>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
            <version>2.4</version>
        </plugin>

        <plugin>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.5</version>
            <configuration>

            </configuration>
        </plugin>

        <plugin>
            <artifactId>maven-deploy-plugin</artifactId>
            <version>2.8.2</version>
            <executions>
                <execution>
                    <id>deploy</id>
                    <phase>deploy</phase>
                    <goals>
                        <goal>deploy</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

        <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.2</version>
            <configuration>
                <url>http://localhost:8080/manager/text</url>
                <server>Tomcat8_local</server>
                <path>/ra-okhs</path>
            </configuration>
        </plugin>

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

<profiles>
    <profile>
        <id>m2e</id>
        <activation>
            <property>
                <name>m2e.version</name>
            </property>
        </activation>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>gwt-maven-plugin</artifactId>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>

推荐答案

解决方案1 ​​

问题是eventbinder依赖于gwt-user工件.它默认使用2.6.0,您可以通过此命令查看它.

The problem is eventbinder has dependency on gwt-user artifact. it uses 2.6.0 by default you can see it by using this command.

mvn dependency:tree

如果将此依赖项块添加到pom;

If you add this dependency block to your pom;

<dependency>
   <groupId>com.google.gwt</groupId>
   <artifactId>gwt-user</artifactId>
   <version>2.7.0</version>
</dependency>

它看起来像这样...

It will look like this...

这意味着您的项目将一直有gwt-user 2.7.0,我还没有测试过版本兼容性是否还可以,或者您的问题是否可以解决..

This means your project will have gwt-user 2.7.0 all the time, i haven't tested if everything is ok with version compatibility or something your problem will be solved..

解决方案2 感谢@Thomas Broyer的评论,我们可以强制eventbinder使用2.7.0 gwt-user或任何gwt依赖项.如果我们仅将此依赖项管理添加到pom

Solution 2Thanks for the @Thomas Broyer's comment we can force eventbinder to use 2.7.0 gwt-user or any gwt dependency. if we just add this dependency management to our pom

<dependencyManagement>
 <dependencies>
  <dependency>
    <groupId>com.google.gwt</groupId>
    <artifactId>gwt</artifactId>
    <version>2.7.0</version>
    <type>pom</type>
    <scope>import</scope>
  </dependency>
 </dependencies>
</dependencyManagement>

结果:

这篇关于如何强制依赖项包含具有特定版本号的工件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 08:20