Maven 依赖的 JAR 版本与 pom.xml 中的规范不同。

huangapple go评论69阅读模式
英文:

Maven dependency jar version is different from pom.xml specification

问题

我一直在收到以下异常:
Caused by: java.nio.file.NoSuchFileException: C:\Program Files\Apache Software Foundation\Tomcat 9.0\wtpwebapps\WebApp\WEB-INF\lib\jackson-databind-2.9.6.jar

我在我的pom.xml文件中有依赖版本2.9.6,但是我的Maven依赖文件夹中却有jackson-databind-2.11.2.jar。

有人知道这个问题的原因或者如何解决吗?
为什么一开始就有jackson-databind-2.11.2.jar呢?

这是我的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.ipomoea</groupId>
  <artifactId>WebApp</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>

  <name>Webapp</name>
  <!-- FIXME change it to the project's website -->
  <url>http://www.example.com</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.7</maven.compiler.source>
    <maven.compiler.target>1.7</maven.compiler.target>
  </properties>

  <dependencies>
		<dependency>
		     <groupId>junit</groupId>
		     <artifactId>junit</artifactId>
		     <version>4.11</version>
		     <scope>test</scope>
		   </dependency>
		   <dependency>
			<groupId>javax.servlet</groupId>
			<artifactId>javax.servlet-api</artifactId>
			<version>3.1.0</version>
		</dependency>
		<!-- https://mvnrepository.com/artifact/javax.activation/activation -->
		<dependency>
		    <groupId>javax.activation</groupId>
		    <artifactId>activation</artifactId>
		    <version>1.1.1</version>
		</dependency>
		<dependency>
			<!-- Reference JPA provider, substitute with another JPA provider as desired-->
			<groupId>org.eclipse.persistence</groupId>
			<artifactId>eclipselink</artifactId>
			<version>2.7.7</version>
		</dependency>
		<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
		<dependency>
		    <groupId>org.hibernate</groupId>
		    <artifactId>hibernate-core</artifactId>
		    <version>5.4.18.Final</version>
		</dependency>
		<dependency>
		    <groupId>mysql</groupId>
		    <artifactId>mysql-connector-java</artifactId>
		    <version>8.0.11</version>
		</dependency>
		<!-- FIDO --><!-- https://mvnrepository.com/artifact/com.yubico/webauthn-server-core -->
		<dependency>
		    <groupId>com.yubico</groupId>
		    <artifactId>webauthn-server-core</artifactId>
		    <version>1.6.1</version>
		</dependency>
		<dependency>
		    <groupId>com.yubico</groupId>
		    <artifactId>webauthn-server-attestation</artifactId>
		    <!--Check for the latest version at Maven Central-->
		    <version>1.2.0</version>
		    <scope>compile</scope>
		</dependency>
		<!-- https://mvnrepository.com/artifact/org.bouncycastle/bcprov-jdk15on -->
		<dependency>
		    <groupId>org.bouncycastle</groupId>
		    <artifactId>bcprov-jdk15on</artifactId>
		    <version>1.66</version>
		</dependency>
		<dependency>
		    <groupId>com.upokecenter</groupId>
		    <artifactId>cbor</artifactId>
		    <version>4.2.0</version>
		</dependency>
		<!-- https://mvnrepository.com/artifact/org.checkerframework/checker-qual -->
		<dependency>
		    <groupId>org.checkerframework</groupId>
		    <artifactId>checker-qual</artifactId>
		    <version>2.11.1</version>
		</dependency>
		<!-- https://mvnrepository.com/artifact/javax.ws.rs/javax.ws.rs-api -->
		<dependency>
		    <groupId>javax.ws.rs</groupId>
		    <artifactId>javax.ws.rs-api</artifactId>
		    <version>2.0</version>
		</dependency>
		<!-- https://mvnrepository.com/artifact/com.yubico/yubico-util -->
		<dependency>
		    <groupId>com.yubico</groupId>
		    <artifactId>yubico-util</artifactId>
		    <version>1.6.4</version>
		</dependency>
		<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.datatype/jackson-datatype-jdk8 -->
		<dependency>
		    <groupId>com.fasterxml.jackson.datatype</groupId>
		    <artifactId>jackson-datatype-jdk8</artifactId>
		    <version>2.11.2</version>
		</dependency>
		<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->
		<dependency>
		    <groupId>com.fasterxml.jackson.core</groupId>
		    <artifactId>jackson-core</artifactId>
		    <version>2.9.9</version>
		</dependency>
		<!-- https://mvnrepository.com/artifact/commons-codec/commons-codec -->
		<dependency>
		    <groupId>commons-codec</groupId>
		    <artifactId>commons-codec</artifactId>
		    <version>1.9</version>
		</dependency><!-- https://mvnrepository.com/artifact/com.augustcellars.cose/cose-java -->
		<dependency>
		    <groupId>com.augustcellars.cose</groupId>
		    <artifactId>cose-java</artifactId>
		    <version>0.9.4</version>
		</dependency>
		<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-annotations -->
		<dependency>
		    <groupId>com.fasterxml.jackson.core</groupId>
		    <artifactId>jackson-annotations</artifactId>
		    <version>2.9.0</version>
		</dependency>
		<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.dataformat/jackson-dataformat-cbor -->
		<dependency>
		    <groupId

<details>
<summary>英文:</summary>

I keep getting the
**Caused by: java.nio.file.NoSuchFileException: C:\Program Files\Apache Software Foundation\Tomcat 9.0\wtpwebapps\WebApp\WEB-INF\lib\jackson-databind-2.9.6.jar**
exception.
I have the dependency version 2.9.6 in my pom.xml file but the jackson-databind-2.11.2.jar in my Maven dependencies folder.

Does anyone know the reason for this or how to solve this?
Why is the jackson-databind-2.11.2.jar there in the first place?

This is my pom.xml file:

```&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;

&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
  xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;

  &lt;groupId&gt;com.ipomoea&lt;/groupId&gt;
  &lt;artifactId&gt;WebApp&lt;/artifactId&gt;
  &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
  &lt;packaging&gt;war&lt;/packaging&gt;

  &lt;name&gt;Webapp&lt;/name&gt;
  &lt;!-- FIXME change it to the project&#39;s website --&gt;
  &lt;url&gt;http://www.example.com&lt;/url&gt;

  &lt;properties&gt;
    &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
    &lt;maven.compiler.source&gt;1.7&lt;/maven.compiler.source&gt;
    &lt;maven.compiler.target&gt;1.7&lt;/maven.compiler.target&gt;
  &lt;/properties&gt;

  &lt;dependencies&gt;
		&lt;dependency&gt;
		     &lt;groupId&gt;junit&lt;/groupId&gt;
		     &lt;artifactId&gt;junit&lt;/artifactId&gt;
		     &lt;version&gt;4.11&lt;/version&gt;
		     &lt;scope&gt;test&lt;/scope&gt;
		   &lt;/dependency&gt;
		   &lt;dependency&gt;
			&lt;groupId&gt;javax.servlet&lt;/groupId&gt;
			&lt;artifactId&gt;javax.servlet-api&lt;/artifactId&gt;
			&lt;version&gt;3.1.0&lt;/version&gt;
		&lt;/dependency&gt;
		&lt;!-- https://mvnrepository.com/artifact/javax.activation/activation --&gt;
		&lt;dependency&gt;
		    &lt;groupId&gt;javax.activation&lt;/groupId&gt;
		    &lt;artifactId&gt;activation&lt;/artifactId&gt;
		    &lt;version&gt;1.1.1&lt;/version&gt;
		&lt;/dependency&gt;
		&lt;dependency&gt;
			&lt;!-- Reference JPA provider, substitute with another JPA provider as desired--&gt;
			&lt;groupId&gt;org.eclipse.persistence&lt;/groupId&gt;
			&lt;artifactId&gt;eclipselink&lt;/artifactId&gt;
			&lt;version&gt;2.7.7&lt;/version&gt;
		&lt;/dependency&gt;
		&lt;!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core --&gt;
		&lt;dependency&gt;
		    &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
		    &lt;artifactId&gt;hibernate-core&lt;/artifactId&gt;
		    &lt;version&gt;5.4.18.Final&lt;/version&gt;
		&lt;/dependency&gt;
		&lt;dependency&gt;
		    &lt;groupId&gt;mysql&lt;/groupId&gt;
		    &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
		    &lt;version&gt;8.0.11&lt;/version&gt;
		&lt;/dependency&gt;
		&lt;!-- FIDO --&gt;&lt;!-- https://mvnrepository.com/artifact/com.yubico/webauthn-server-core --&gt;
		&lt;dependency&gt;
		    &lt;groupId&gt;com.yubico&lt;/groupId&gt;
		    &lt;artifactId&gt;webauthn-server-core&lt;/artifactId&gt;
		    &lt;version&gt;1.6.1&lt;/version&gt;
		&lt;/dependency&gt;
		&lt;dependency&gt;
		    &lt;groupId&gt;com.yubico&lt;/groupId&gt;
		    &lt;artifactId&gt;webauthn-server-attestation&lt;/artifactId&gt;
		    &lt;!--Check for the latest version at Maven Central--&gt;
		    &lt;version&gt;1.2.0&lt;/version&gt;
		    &lt;scope&gt;compile&lt;/scope&gt;
		&lt;/dependency&gt;
		&lt;!-- https://mvnrepository.com/artifact/org.bouncycastle/bcprov-jdk15on --&gt;
		&lt;dependency&gt;
		    &lt;groupId&gt;org.bouncycastle&lt;/groupId&gt;
		    &lt;artifactId&gt;bcprov-jdk15on&lt;/artifactId&gt;
		    &lt;version&gt;1.66&lt;/version&gt;
		&lt;/dependency&gt;
		&lt;dependency&gt;
		    &lt;groupId&gt;com.upokecenter&lt;/groupId&gt;
		    &lt;artifactId&gt;cbor&lt;/artifactId&gt;
		    &lt;version&gt;4.2.0&lt;/version&gt;
		&lt;/dependency&gt;
		&lt;!-- https://mvnrepository.com/artifact/org.checkerframework/checker-qual --&gt;
		&lt;dependency&gt;
		    &lt;groupId&gt;org.checkerframework&lt;/groupId&gt;
		    &lt;artifactId&gt;checker-qual&lt;/artifactId&gt;
		    &lt;version&gt;2.11.1&lt;/version&gt;
		&lt;/dependency&gt;
		&lt;!-- https://mvnrepository.com/artifact/javax.ws.rs/javax.ws.rs-api --&gt;
		&lt;dependency&gt;
		    &lt;groupId&gt;javax.ws.rs&lt;/groupId&gt;
		    &lt;artifactId&gt;javax.ws.rs-api&lt;/artifactId&gt;
		    &lt;version&gt;2.0&lt;/version&gt;
		&lt;/dependency&gt;
		&lt;!-- https://mvnrepository.com/artifact/com.yubico/yubico-util --&gt;
		&lt;dependency&gt;
		    &lt;groupId&gt;com.yubico&lt;/groupId&gt;
		    &lt;artifactId&gt;yubico-util&lt;/artifactId&gt;
		    &lt;version&gt;1.6.4&lt;/version&gt;
		&lt;/dependency&gt;
		&lt;!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.datatype/jackson-datatype-jdk8 --&gt;
		&lt;dependency&gt;
		    &lt;groupId&gt;com.fasterxml.jackson.datatype&lt;/groupId&gt;
		    &lt;artifactId&gt;jackson-datatype-jdk8&lt;/artifactId&gt;
		    &lt;version&gt;2.11.2&lt;/version&gt;
		&lt;/dependency&gt;
		&lt;!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core --&gt;
		&lt;dependency&gt;
		    &lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt;
		    &lt;artifactId&gt;jackson-core&lt;/artifactId&gt;
		    &lt;version&gt;2.9.9&lt;/version&gt;
		&lt;/dependency&gt;
		&lt;!-- https://mvnrepository.com/artifact/commons-codec/commons-codec --&gt;
		&lt;dependency&gt;
		    &lt;groupId&gt;commons-codec&lt;/groupId&gt;
		    &lt;artifactId&gt;commons-codec&lt;/artifactId&gt;
		    &lt;version&gt;1.9&lt;/version&gt;
		&lt;/dependency&gt;&lt;!-- https://mvnrepository.com/artifact/com.augustcellars.cose/cose-java --&gt;
		&lt;dependency&gt;
		    &lt;groupId&gt;com.augustcellars.cose&lt;/groupId&gt;
		    &lt;artifactId&gt;cose-java&lt;/artifactId&gt;
		    &lt;version&gt;0.9.4&lt;/version&gt;
		&lt;/dependency&gt;
		&lt;!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-annotations --&gt;
		&lt;dependency&gt;
		    &lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt;
		    &lt;artifactId&gt;jackson-annotations&lt;/artifactId&gt;
		    &lt;version&gt;2.9.0&lt;/version&gt;
		&lt;/dependency&gt;
		&lt;!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.dataformat/jackson-dataformat-cbor --&gt;
		&lt;dependency&gt;
		    &lt;groupId&gt;com.fasterxml.jackson.dataformat&lt;/groupId&gt;
		    &lt;artifactId&gt;jackson-dataformat-cbor&lt;/artifactId&gt;
		    &lt;version&gt;2.9.6&lt;/version&gt;
		&lt;/dependency&gt;
		&lt;!-- https://mvnrepository.com/artifact/commons-logging/commons-logging --&gt;
		&lt;dependency&gt;
		    &lt;groupId&gt;commons-logging&lt;/groupId&gt;
		    &lt;artifactId&gt;commons-logging&lt;/artifactId&gt;
		    &lt;version&gt;1.2&lt;/version&gt;
		&lt;/dependency&gt;
		&lt;!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient --&gt;
		&lt;dependency&gt;
		    &lt;groupId&gt;org.apache.httpcomponents&lt;/groupId&gt;
		    &lt;artifactId&gt;httpclient&lt;/artifactId&gt;
		    &lt;version&gt;4.5.2&lt;/version&gt;
		&lt;/dependency&gt;
		&lt;!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind --&gt;
		&lt;dependency&gt;
		    &lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt;
		    &lt;artifactId&gt;jackson-databind&lt;/artifactId&gt;
		    &lt;version&gt;2.9.6&lt;/version&gt;
		&lt;/dependency&gt;
  &lt;/dependencies&gt;

  &lt;build&gt;
    &lt;finalName&gt;WebApp&lt;/finalName&gt;
    &lt;pluginManagement&gt;&lt;!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) --&gt;
      &lt;plugins&gt;
        &lt;plugin&gt;
          &lt;artifactId&gt;maven-clean-plugin&lt;/artifactId&gt;
          &lt;version&gt;3.1.0&lt;/version&gt;
        &lt;/plugin&gt;
        &lt;!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging --&gt;
        &lt;plugin&gt;
          &lt;artifactId&gt;maven-resources-plugin&lt;/artifactId&gt;
          &lt;version&gt;3.0.2&lt;/version&gt;
        &lt;/plugin&gt;
        &lt;plugin&gt;
          &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
          &lt;version&gt;3.8.0&lt;/version&gt;
        &lt;/plugin&gt;
        &lt;plugin&gt;
          &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
          &lt;version&gt;2.22.1&lt;/version&gt;
        &lt;/plugin&gt;
        &lt;plugin&gt;
          &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt;
          &lt;version&gt;3.2.2&lt;/version&gt;
        &lt;/plugin&gt;
        &lt;plugin&gt;
          &lt;artifactId&gt;maven-install-plugin&lt;/artifactId&gt;
          &lt;version&gt;2.5.2&lt;/version&gt;
        &lt;/plugin&gt;
        &lt;plugin&gt;
          &lt;artifactId&gt;maven-deploy-plugin&lt;/artifactId&gt;
          &lt;version&gt;2.8.2&lt;/version&gt;
        &lt;/plugin&gt;
      &lt;/plugins&gt;
    &lt;/pluginManagement&gt;
  &lt;/build&gt;
&lt;/project&gt;

答案1

得分: 0

如果您正在使用Eclipse,您可以右键单击您的项目,然后选择Maven > 更新项目(Project...),接着选中"Force Update of Snapshots/Releases"复选框,然后点击OK。

如果您正在使用IntelliJ,右键单击您的项目,然后选择Maven > 重新导入(Reimport)。

最终您可以尝试通过终端,在项目的根目录下执行mvn clean install,或者如果项目中有Maven Wrapper,您可以在Windows上执行mvnw clean install,在Linux上执行./mvnw clean install

英文:

If you are using eclipse you can right-click on your project then Maven > Update Project..., then select Force Update of Snapshots/Releases checkbox then click OK.

If you are using Intellij right-click on your project then Maven > Reimport

Eventually you can try through terminal while in the root directory of the project mvn clean install or if you have maven wrapper in your project mvnw clean install on windows or ./mvnw clean install on linux.

huangapple
  • 本文由 发表于 2020年8月23日 03:45:34
  • 转载请务必保留本文链接:https://go.coder-hub.com/63540435.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定