使用 axis2-wsdl2code-maven-plugin 生成 SOAP 客户端时出现 Log4j 警告

Log4j warning while using axis2-wsdl2code-maven-plugin to generate SOAP client

我正在使用 axis2-wsdl2code-maven-plugin 生成我的 SOAP 服务客户端。插件本身工作正常,并且生成正确的 SOAP 客户端,但每次构建时我都会在控制台中收到以下警告:

log4j:WARN No appenders could be found for logger (org.apache.axiom.locator.DefaultOMMetaFactoryLocator).
log4j:WARN Please initialize the log4j system properly.

我知道我需要配置 Log4j 属性,但我还没有找到在 axis2-wsdl2code-maven-plugin...

上下文中执行此操作的任何实用方法

这是我的 pom.xml 文件:

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

    <artifactId>powerauth-java-client-axis</artifactId>
    <version>0.13.0</version>
    <name>powerauth-java-client-axis</name>
    <description>PowerAuth 2.0 Service Client - Axis</description>

    <parent>
        <groupId>io.getlime.security</groupId>
        <artifactId>powerauth-parent</artifactId>
        <version>0.13.0</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <dependencies>
        <dependency>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2</artifactId>
            <version>1.6.3</version>
        </dependency>
        <dependency>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-adb</artifactId>
            <version>1.6.3</version>
        </dependency>
        <dependency>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-transport-http</artifactId>
            <version>1.6.3</version>
        </dependency>
        <dependency>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-transport-local</artifactId>
            <version>1.6.3</version>
        </dependency>
        <dependency>
            <groupId>org.apache.ws.commons.axiom</groupId>
            <artifactId>axiom-api</artifactId>
            <version>1.2.20</version>
        </dependency>
        <dependency>
            <groupId>org.apache.ws.commons.axiom</groupId>
            <artifactId>axiom-impl</artifactId>
            <version>1.2.20</version>
        </dependency>
        <dependency>
            <groupId>org.apache.ws.security</groupId>
            <artifactId>wss4j</artifactId>
            <version>1.6.19</version>
        </dependency>
        <dependency>
            <groupId>wsdl4j</groupId>
            <artifactId>wsdl4j</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <!-- tag::wsdl[] -->
            <plugin>
                <groupId>org.apache.axis2</groupId>
                <artifactId>axis2-wsdl2code-maven-plugin</artifactId>
                <version>1.6.4</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>wsdl2code</goal>
                        </goals>
                        <configuration>
                            <packageName>io.getlime.powerauth.soap</packageName>
                            <wsdlFile>${basedir}/src/main/resources/soap/wsdl/service.wsdl</wsdlFile>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!-- end::wsdl[] -->
        </plugins>
    </build>

</project>

这实际上是一个错误。 fix for AXIS2-5364 向 axis2-wsdl2code-maven-plugin 添加了对 log4j 的依赖。问题是插件执行的一些代码使用了 Commons Logging,因此开始使用 log4j。这会生成您看到的警告,因为在 Maven 环境中,未配置 log4j。

插件应该做的是将日志重定向到 SLF4J,因为 API 是 supported by recent Maven versions-X 选项(在 Maven 命令行上启用调试日志记录)然后也适用于这些日志。

此问题将在 AXIS2-5827 中解决。