Eclipse构建战争成功,但Maven命令canot

问题描述 投票:0回答:2

我在Java 8 JDK上编写Java 7代码

mvn clean install

它显示错误

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project foo: Compilation failure: Compilation failure:
[ERROR] /E:/bar/XmlUtils.java:[9,44] package com.sun.xml.internal.bind.marshaller does not exist
[ERROR] /E:/bar/XmlUtils.java:[11,34] cannot find symbol
[ERROR] symbol: class CharacterEscapeHandler
[ERROR] /E:/.../FooServiceImpl.java:[106,44] package com.sun.xml.internal.bind.marshall

这是代码行生成错误

CharacterEscapeHandler.class.getName()

Maven找不到import com.sun.xml.internal.bind.marshaller.CharacterEscapeHandler;

Maven找不到CharacterEscapeHandle。怎么解决?

但是当我构建,打包,运行Eclipse Neon时,没问题。怎么解决?

java eclipse maven
2个回答
1
投票

通常,您不应使用com.sun.xml.internal包中的任何代码。这故意失败。这里有更多细节:https://bugs.java.com/bugdatabase/view_bug.do;jsessionid=1711ee4eae3ff10565fc7a212018?bug_id=6778491


-2
投票

这是临时解决方案

    <dependency>
        <groupId>sun.jdk</groupId>
        <artifactId>rt.jar</artifactId>
        <version>1.8</version>
        <scope>system</scope>
        <systemPath>${java.home}/lib/rt.jar</systemPath>
    </dependency>
</dependencies>
<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.6.1</version>
                <configuration>
                    <fork>true</fork>
                    <compilerArgument>-XDignore.symbol.file</compilerArgument>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

Maven建立成功。

© www.soinside.com 2019 - 2024. All rights reserved.