eclipse - 使用 m2e : Couldn't find that class org. apache.cxf.pmd.UnsafeStringConstructorRule 将 cxf 项目导入 eclipse 时出错

标签 eclipse maven cxf m2e pmd

我查看了 cxf 源代码并尝试使用“import as maven project”将项目导入到 eclipse 中。

然后我收到错误:无法找到该类 org.apache.cxf.pmd.UnsafeStringConstructorRule 来自 m2e。

所以看起来 cxf 在那里定义了一个规则,而 pmd 插件找不到它。 有什么想法吗?

最佳答案

关于Apache CXF parent pom ,它提到了名为 m2eclipseprofile,它定义了 maven-pmd-plugin 以及依赖项,如下所示: -

<profile>
    <id>m2eclipse</id>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-pmd-plugin</artifactId>
                <version>2.7.1</version>
                <dependencies>
                    <dependency>
                        <groupId>org.apache.cxf.build-utils</groupId>
                        <artifactId>cxf-buildtools</artifactId>
                        <version>${cxf.build-utils.version}</version>
                    </dependency>
                </dependencies>
                <configuration>
                    <rulesets>
                        <ruleset>
                            ${cxf.resources.base.path}cxf-pmd-ruleset.xml
                        </ruleset>
                    </rulesets>
                    <sourceEncoding>UTF-8</sourceEncoding>
                    <targetJdk>1.6</targetJdk>
                    <linkXRef>false</linkXRef>
                    <includeTests>true</includeTests>
                    <verbose>true</verbose>
                    <excludeRoots>
                        <excludeRoot>${basedir}/src/main/generated</excludeRoot>
                    </excludeRoots>
                </configuration>
                <executions>
                    <execution>
                        <id>validate</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</profile>

您可能会注意到此配置文件中没有任何激活

下载org.apache.cxf.build-utils:cxf-buildtools:2.5.0:jar表单后Maven Central Repository ,我还找到了名为 org.apache.cxf.pmd.UnsafeStringConstructorRule 的类。

这可能是您问题的根本原因。恕我直言,您可以尝试通过缺少某些属性来激活此配置文件,例如

<profile>
    <id>m2eclipse</id>
    <activation>
        <property>
           <name>!skipM2E</name>
        </property>
    </activation>
    ....
</profile>

希望这会有所帮助。

关于eclipse - 使用 m2e : Couldn't find that class org. apache.cxf.pmd.UnsafeStringConstructorRule 将 cxf 项目导入 eclipse 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16085263/

相关文章:

java - 如何在maven .m2文件夹中设置多个设置文件?

java - 如何创建具有外部资源配置的 uber-jar

web-services - CXF 服务器 - 启用 ssl 空密码

ssl - 带 Camel 的 CXF - HTTPS

java - 在 Eclipse 中,如何在 Javadoc 中显示泛型类型约束?

android - Android 中 Cocos2d-X 的 TDD

java - 无法在eclipse中打开jar文件

java - Maven 使用错误的类目录创建 war ,或者将已编译的类放在错误的位置

java - 使用 CXF : NoClassDefFoundError: SOAPFaultBuilder 捕获 Web 服务异常

java.lang.SecurityException : class "org.eclipse.core.runtime.PlatformObject"'s signer information does not match signer information 错误