繁体   English   中英

maven汇编:未解决的编译错误

[英]maven assembly: unresolved compilation error

我有一个使用Maven的应用程序用maven-assembly-plugin构建一个JAR。

该项目包括一个依赖项列表,其中一个是另一个Maven项目。 我正在使用Eclipse进行开发,当我运行该项目时,一切正常。 当我使用Maven目标assembly:assembly构建时,它会生成JAR但是当我运行JAR时它会给我这个错误:

Exception in thread "main" java.lang.Error: Unresolved compilation problem: 
    The method configure(Map<String,String>) of type SMTPMailService must 
      override a superclass method
    at rey.sto.utils.mail.SMTPMailService.configure(SMTPMailService.java:89)
    at com.ppl_sftp.transfer.FileTransfer.startTransfer(FileTransfer.java:232)
    at com.ppl_sftp.transfer.MainApp.main(MainApp.java:33)

这是主项目的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/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

<groupId>com.ppl-sftp</groupId>
<artifactId>transfer</artifactId>
<packaging>jar</packaging>
<version>0.0.1-SNAPSHOT</version>

<name>A Camel Route</name>
<url>http://www.myorganization.org</url>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>

<dependencies>
    <!-- logging -->

    <!-- testing -->
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-core</artifactId>
        <version>2.10.0</version>
        <type>jar</type>
        <optional>false</optional>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.6.6</version>
        <type>jar</type>
        <optional>false</optional>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>1.6.6</version>
        <type>jar</type>
        <optional>false</optional>
    </dependency>
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.16</version>
        <type>jar</type>
        <optional>false</optional>
    </dependency>
    <dependency>
        <groupId>org.xerial</groupId>
        <artifactId>sqlite-jdbc</artifactId>
        <version>3.7.2</version>
        <type>jar</type>
        <optional>false</optional>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-test</artifactId>
        <version>2.10.0</version>
        <type>jar</type>
        <scope>test</scope>
        <optional>false</optional>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-ftp</artifactId>
        <version>2.9.2</version>
        <type>jar</type>
        <optional>false</optional>
    </dependency>

    <dependency>
        <groupId>my-utils</groupId>
        <artifactId>my-utils</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </dependency>
    <dependency>
         <groupId>javax.activation</groupId>
         <artifactId>activation</artifactId>
         <version>1.1</version>
        </dependency>
    <dependency>
        <groupId>com.sun.mail</groupId>
        <artifactId>javax.mail</artifactId>
        <version>1.4.5</version>
    </dependency>
</dependencies>

<build>
    <defaultGoal>install</defaultGoal>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.5</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
        <!-- allows the route to be ran via 'mvn camel:run' -->
        <plugin>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-maven-plugin</artifactId>
            <version>2.10.0</version>
        </plugin>
        <!-- Allows the example to be run via 'mvn compile exec:java' -->
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>1.2.1</version>
            <configuration>
                <mainClass>com.ppl_sftp.transfer.MainApp</mainClass>
                <includePluginDependencies>false</includePluginDependencies>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <configuration>
                <archive>
                    <manifest>
                        <mainClass>com.ppl_sftp.transfer.MainApp</mainClass>
                    </manifest>
                </archive>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
            </configuration>
        </plugin>
    </plugins>
</build>

这是my-utils项目依赖项的pom:

<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>rey-sto-utils</groupId>
<artifactId>rey-sto-utils</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.5</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
    </plugins>
</build>
<dependencies>
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>2.0-beta2</version>
        <type>pom</type>
    </dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.21</version>
    </dependency>
    <dependency>
        <groupId>ojdbc6</groupId>
        <artifactId>ojdbc6</artifactId>
        <version>6</version>
    </dependency>
    <dependency>
        <groupId>javax.activation</groupId>
        <artifactId>activation</artifactId>
        <version>1.1</version>
    </dependency>
    <dependency>
        <groupId>com.sun.mail</groupId>
        <artifactId>javax.mail</artifactId>
        <version>1.4.5</version>
    </dependency>
</dependencies>

该问题与Java邮件依赖性有关。 正如您所看到的,我使用过com.sun.mail但我看到了一些与javax.mail对应的其他库。

也许我错过了我的poms中的一些东西,比如配置参数或插件。

我也尝试在我的本地存储库中放入一个在其他项目中工作正常的mail.jar,但是我得到了同样的错误。

“未解决的编译问题”来自Eclipse已编译的utils项目中的类文件,但Eclipse无法正确编译它。

您看到Eclipse和Maven的不同结果的原因是他们使用的是不同版本的类文件。 Eclipse正在进行工作区解析,因此它在utils / target / classes中使用SMTPMailService的版本。 Maven正在从您的本地Maven存储库中解析utils jar,当您在Eclipse中编译错误时,通过运行mvn install将其放在那里。

尝试在utils项目中运行mvn clean install (清除以删除Eclipse生成的任何类文件,安装以替换本地存储库中的jar)。 然后重建你的程序集。

暂无
暂无

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

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