Mule-Requester 无法在 Maven 中编译

Mule-Requester failing to compile in Maven

我们有一个 Maven 项目,我们正在尝试使用 mule 请求程序从路径中读取文件。我们已经在 pom.xml 中添加了所需的依赖项,但是当我们尝试编译文件时,它失败并给出以下错误: java.lang.UnsupportedClassVersionError:

java.lang.UnsupportedClassVersionError: org/mule/module/generated/config/MulerequesterNamespaceHandler : Unsupported major.minor version 52.0

下面是我的pom.xml

<?xml version="1.0" encoding="UTF-8" standalone="no"?>

http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>
<groupId>nhs.sbs</groupId>
<artifactId>nhs-sample-file-java</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>mule</packaging>
<name>Mule nhs-sample-file-java Application</name>

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

    <mule.version>3.8.1</mule.version>
    <mule.tools.version>1.2</mule.tools.version>
</properties>

<build>
    <plugins>
        <plugin>
            <groupId>org.mule.tools.maven</groupId>
            <artifactId>mule-app-maven-plugin</artifactId>
            <version>${mule.tools.version}</version>
            <extensions>true</extensions>
            <configuration>
                <copyToAppsDirectory>true</copyToAppsDirectory>
            <inclusions>
                    <inclusion>
                        <groupId>org.mule.modules</groupId>
                        <artifactId>mule-module-requester</artifactId>
                    </inclusion>
                </inclusions>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.2.1</version>
            <configuration>
                <descriptorRefs>
                    <descriptorRef>project</descriptorRef>
                </descriptorRefs>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <version>1.7</version>
            <executions>
                <execution>
                    <id>add-resource</id>
                    <phase>generate-resources</phase>
                    <goals>
                        <goal>add-resource</goal>
                    </goals>
                    <configuration>
                        <resources>
                            <resource>
                                <directory>src/main/app/</directory>
                            </resource>
                            <resource>
                                <directory>mappings/</directory>
                            </resource>
                        </resources>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

<!-- Mule Dependencies -->
<dependencies>
    <!-- Xml configuration -->
    <dependency>
        <groupId>com.mulesoft.muleesb</groupId>
        <artifactId>mule-core-ee</artifactId>
        <version>${mule.version}</version>
        <scope>provided</scope>
    </dependency>
    <!-- Xml configuration -->
    <dependency>
        <groupId>com.mulesoft.muleesb.modules</groupId>
        <artifactId>mule-module-spring-config-ee</artifactId>
        <version>${mule.version}</version>
        <scope>provided</scope>
    </dependency>
    <!-- Mule Transports -->
    <dependency>
        <groupId>org.mule.transports</groupId>
        <artifactId>mule-transport-file</artifactId>
        <version>${mule.version}</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.mule.transports</groupId>
        <artifactId>mule-transport-http</artifactId>
        <version>${mule.version}</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.mulesoft.muleesb.transports</groupId>
        <artifactId>mule-transport-jdbc-ee</artifactId>
        <version>${mule.version}</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.mulesoft.muleesb.transports</groupId>
        <artifactId>mule-transport-jms-ee</artifactId>
        <version>${mule.version}</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.mule.transports</groupId>
        <artifactId>mule-transport-vm</artifactId>
        <version>${mule.version}</version>
        <scope>provided</scope>
    </dependency>
    <!-- Mule Modules -->
    <dependency>
        <groupId>org.mule.modules</groupId>
        <artifactId>mule-module-scripting</artifactId>
        <version>${mule.version}</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.mule.modules</groupId>
        <artifactId>mule-module-xml</artifactId>
        <version>${mule.version}</version>
        <scope>provided</scope>
    </dependency>
    <!-- for testing -->
    <dependency>
        <groupId>org.mule.tests</groupId>
        <artifactId>mule-tests-functional</artifactId>
        <version>${mule.version}</version>
        <scope>test</scope>
    </dependency>
<dependency>
        <groupId>org.mule.modules</groupId>
        <artifactId>mule-module-http</artifactId>
        <version>${mule.version}</version>
        <scope>provided</scope>
    </dependency>
<dependency>
        <groupId>cglib</groupId>
        <artifactId>cglib</artifactId>
        <version>3.2.2</version>
        <scope>provided</scope>
    </dependency>
<dependency>
        <groupId>org.mule.modules</groupId>
        <artifactId>mule-module-requester</artifactId>
        <version>1.5</version>
    </dependency>
</dependencies>

<repositories>
      <repository>
        <id>Central</id>
        <name>Central</name>
        <url>http://repo1.maven.org/maven2/</url>
        <layout>default</layout>
    </repository>
    <repository>
        <id>mulesoft-releases</id>
        <name>MuleSoft Releases Repository</name>
        <url>http://repository.mulesoft.org/releases/</url>
        <layout>default</layout>
    </repository>
<repository>
        <id>muleforge-releases</id>
        <name>MuleForge Snapshot Repository</name>
        <url>https://repository-master.mulesoft.org/nexus/content/repositories/releases/</url>
    </repository>
</repositories>
<pluginRepositories>
    <pluginRepository>
        <id>mulesoft-release</id>
        <name>mulesoft release repository</name>
        <layout>default</layout>
        <url>http://repository.mulesoft.org/releases/</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </pluginRepository>
</pluginRepositories>

而我的申请xml如下图:

<flow name="nhs-sample-file-javaFlow">
    <http:listener config-ref="HTTP_Listener_Configuration" path="/filejava" doc:name="HTTP"/>
    <logger message="Start of the application" level="INFO" doc:name="Logger"/>
    <mulerequester:request resource="/mw_shared/mule/data/civica_icon/Inbound/Archive/SBSCIVICA16052017.txt" doc:name="Mule Requester"/>
    <logger message="#[payload]" level="INFO" doc:name="Logger"/>
</flow>

您使用的是 java 1.8 吗?我尝试使用 1.8,但没有发现任何问题。

问题是因为 Java 版本不匹配。

有关不受支持的 major.minor 版本的错误是因为在编译时您使用的是更高的 JDK 和运行时 JDK 的较低的 JDK

根据您的情况,您使用的是 JDK 1.7,正如您提到的 Mule 请求者 v1.4 具有 JDK 1.8

所以要解决这个问题,您可以将 JDK 更改为 1.8 或使用 mule requestor v1.3(有 JDK 1.7)

https://repository-master.mulesoft.org/nexus/content/repositories/releases/org/mule/modules/mule-module-requester/1.3

我认为它可以解决您的问题