gpt4 book ai didi

java - Maven 包 org.apache.commons.codec.binary 不存在

转载 作者:搜寻专家 更新时间:2023-11-01 02:58:06 25 4
gpt4 key购买 nike

运行:

mvn编译

产生错误:

包 org.apache.commons.codec.binary 不存在

pom.xml 包括:

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

ls ~/.m2/repository/commons-codec/commons-codec/1.10

返回:

commons-codec-1.10.jar
commons-codec-1.10.jar.sha1
commons-codec-1.10.pom
commons-codec-1.10.pom.sha1
_remote.repositories

jar tvf commons-codec-1.10.jar | grep 二进制文件

返回:

org/apache/commons/codec/binary/
org/apache/commons/codec/binary/Base32.class
org/apache/commons/codec/binary/Base32InputStream.class
org/apache/commons/codec/binary/Base32OutputStream.class
org/apache/commons/codec/binary/Base64.class
org/apache/commons/codec/binary/Base64InputStream.class
org/apache/commons/codec/binary/Base64OutputStream.class
org/apache/commons/codec/binary/BaseNCodec$Context.class
org/apache/commons/codec/binary/BaseNCodec.class
org/apache/commons/codec/binary/BaseNCodecInputStream.class
org/apache/commons/codec/binary/BaseNCodecOutputStream.class
org/apache/commons/codec/binary/BinaryCodec.class
org/apache/commons/codec/binary/CharSequenceUtils.class
org/apache/commons/codec/binary/Hex.class
org/apache/commons/codec/binary/StringUtils.class

代码:

<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>dashboard</groupId>
<artifactId>dashboard</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>Dashboard</name>
<description>Dashboard</description>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.ocpsoft</groupId>
<artifactId>prettyfaces-jsf2</artifactId>
<version>3.3.2</version>
</dependency>
...
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.10</version>
</dependency>
...
</dependencies>
</dependencyManagement>
<repositories>
<repository>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>public-snapshots</id>
<url>http://public-snapshots</url>
</repository>
<repository>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>central</id>
<name>Central Repository</name>
<url>https://repo.maven.apache.org/maven2/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>public-snapshots</id>
<url>http://public-snapshots</url>
</pluginRepository>
<pluginRepository>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>central</id>
<name>Central Plugin Repository</name>
<url>https://repo.maven.apache.org/maven2/</url>
</pluginRepository>
</pluginRepositories>
<build>
<sourceDirectory>/home/username/workspace/MyApp/src</sourceDirectory>
<scriptSourceDirectory>/home/username/workspace/MyApp/src/main/scripts</scriptSourceDirectory>
<testSourceDirectory>/home/username/workspace/MyApp/src/test/java</testSourceDirectory>
<outputDirectory>/home/username/workspace/MyApp/target/classes</outputDirectory>
<testOutputDirectory>/home/username/workspace/MyApp/target/test-classes</testOutputDirectory>
<resources>
<resource>
<directory>/home/username/workspace/MyApp/src</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<testResources>
<testResource>
<directory>/home/username/workspace/MyApp/src/test/resources</directory>
</testResource>
</testResources>
<directory>/home/username/workspace/MyApp/target</directory>
<finalName>dashboard-0.0.1-SNAPSHOT</finalName>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.3</version>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
</plugin>
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>2.3.2</version>
</plugin>


<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.0.2</version>
<executions>
<execution>
<id>analyze</id>
<goals>
<goal>analyze-only</goal>
</goals>
<configuration>
<failOnWarning>true</failOnWarning>
</configuration>
</execution>
</executions>
</plugin>
</plugins>


</pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<executions>
<execution>
<id>default-testCompile</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</execution>
<execution>
<id>default-compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</execution>
</executions>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>default-war</id>
<phase>package</phase>
<goals>
<goal>war</goal>
</goals>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</execution>
</executions>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>default-clean</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>default-install</id>
<phase>install</phase>
<goals>
<goal>install</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>default-resources</id>
<phase>process-resources</phase>
<goals>
<goal>resources</goal>
</goals>
</execution>
<execution>
<id>default-testResources</id>
<phase>process-test-resources</phase>
<goals>
<goal>testResources</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.4</version>
<executions>
<execution>
<id>default-test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.7</version>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.3</version>
<executions>
<execution>
<id>default-site</id>
<phase>site</phase>
<goals>
<goal>site</goal>
</goals>
<configuration>
<outputDirectory>/home/username/workspace/MyApp/target/site</outputDirectory>
<reportPlugins>
<reportPlugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
</reportPlugin>
</reportPlugins>
</configuration>
</execution>
<execution>
<id>default-deploy</id>
<phase>site-deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
<configuration>
<outputDirectory>/home/username/workspace/MyApp/target/site</outputDirectory>
<reportPlugins>
<reportPlugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
</reportPlugin>
</reportPlugins>
</configuration>
</execution>
</executions>
<configuration>
<outputDirectory>/home/username/workspace/MyApp/target/site</outputDirectory>
<reportPlugins>
<reportPlugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
</reportPlugin>
</reportPlugins>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<outputDirectory>/home/username/workspace/MyApp/target/site</outputDirectory>
</reporting>

</project>

错误:

INFO] Compiling 62 source files to /home/username/workspace/MyApp/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /home/username/workspace/MyApp/src/xx/yyy/zzzz/dashboard/webservices/util/fname1.java:[10,39] package org.apache.commons.codec.binary does not exist
[ERROR] /home/username/workspace/MyApp/src/xx/yyy/zzzz/dashboard/webservices/util/fname1.java:[11,29] package org.apache.commons.io does not exist
[ERROR] /home/username/workspace/MyApp/src/xx/yyy/zzzz/dashboard/report/ReportBean.java:[17,24] package javax.faces.bean does not exist
[ERROR] /home/username/workspace/MyApp/src/xx/yyy/zzzz/dashboard/report/ReportBean.java:[18,24] package javax.faces.bean does not exist
[ERROR] /home/username/workspace/MyApp/src/xx/yyy/zzzz/dashboard/report/ReportBean.java:[32,2] cannot find symbol

符号:类ManagedBean

如有任何关于 mvn 无法解析此包的建议,我们将不胜感激。

仅供引用,刚刚开始使用 Maven。

谢谢,

凯文

最佳答案

问题是您在 <dependencyManagement> 下依赖 commons-codec标签。

你应该改变你的标签<dependencyManagement>成为<dependencies>

参见 differences between dependencymanagement and dependencies in maven

关于java - Maven 包 org.apache.commons.codec.binary 不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46591469/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com