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

时间:2017-10-05 17:23:15

标签: java maven apache-commons-codec

运行:

mvn compile

生成错误:

包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 binary

返回:

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

symbol:class ManagedBean

有关为什么mvn无法解析此软件包的任何建议将不胜感激。

仅供参考,刚开始使用maven。

谢谢,

KevinC

1 个答案:

答案 0 :(得分:3)

问题是你在<dependencyManagement>标签下面有commons-codec的依赖关系。

您应该将标记<dependencyManagement>更改为<dependencies>

请参阅differences between dependencymanagement and dependencies in maven