Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何修复此错误:java.lang.NoClassDefFoundError:org/slf4j/impl/StaticLoggerBinder?_Java_Maven_Mule - Fatal编程技术网

如何修复此错误:java.lang.NoClassDefFoundError:org/slf4j/impl/StaticLoggerBinder?

如何修复此错误:java.lang.NoClassDefFoundError:org/slf4j/impl/StaticLoggerBinder?,java,maven,mule,Java,Maven,Mule,当运行maven插件执行其目标“install”时,我得到一个错误,它告诉我“staticloggerbinder”尚未找到 我已经浏览了stackoverflow的每一篇文章,他们在其中讨论了这个错误(显然非常普遍)。他们大多数人建议将以下内容作为一种依赖: <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifac

当运行maven插件执行其目标“install”时,我得到一个错误,它告诉我“staticloggerbinder”尚未找到

我已经浏览了stackoverflow的每一篇文章,他们在其中讨论了这个错误(显然非常普遍)。他们大多数人建议将以下内容作为一种依赖:

    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-log4j12</artifactId>
      <version>1.5.0</version>
    </dependency>
我不知道你们是否需要我的pom.xml,但如果需要,请随时向我索取

干杯

编辑:

POM.xml

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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>...</groupId>
    <artifactId>...</artifactId>
    <version>6.0.0</version>
    <packaging>mule</packaging>
    <name>...</name>

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

        <mule.version>3.7.3</mule.version>
        <mule.tools.version>1.2</mule.tools.version>

        <muleApiUrl>...</muleApiUrl>
        <username>...</username>
        <password>....</password>
        <serverGroup>Development</serverGroup>  
    </properties>

    <build>
        <plugins>

<plugin>
    <groupId>com.github.nicholasastuart</groupId>
    <artifactId>mule-mmc-rest-plugin</artifactId>
    <version>1.2.2</version>
    <executions>
        <execution>
            <id>mule-deploy</id>
            <phase>install</phase>
            <goals>
                <goal>deploy</goal>
            </goals>
            <configuration>
                <muleApiUrl>${muleApiUrl}</muleApiUrl>
                <name>${artifactId}</name>
                <username>${username}</username>
                <password>${password}</password>
                <appDirectory>${project.basedir}/src/main/app</appDirectory>
                <finalName>${artifactId}-${version}</finalName>
                <version>${version}</version>
                <serverGroup>${serverGroup}</serverGroup>                           

            </configuration>
        </execution>
    </executions>
</plugin>



            <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-apikit</artifactId>
                        </inclusion>
                    </inclusions>
                </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>
                            <resource>
                                    <directory>src/main/api/</directory>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <!-- Mule Dependencies -->
    <dependencies>


<dependency>
  <groupId>org.slf4j</groupId>
  <artifactId>slf4j-api</artifactId>
  <version>1.7.21</version> <!-- Or a property: ${sl4j-api.version} -->
</dependency>


<dependency>
  <groupId>org.slf4j</groupId>
  <artifactId>slf4j-log4j12</artifactId>
  <version>1.5.0</version>
</dependency>




        <!-- 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-apikit</artifactId>
            <version>1.7.4</version>
        </dependency>
    <dependency>
            <groupId>org.mule.modules</groupId>
            <artifactId>mule-module-http</artifactId>
            <version>${mule.version}</version>
            <scope>provided</scope>
        </dependency>
    <dependency>
            <groupId>org.mule.modules</groupId>
            <artifactId>mule-module-spring-config</artifactId>
            <version>${mule.version}</version>
            <scope>provided</scope>
        </dependency>
    <dependency>
            <groupId>com.mulesoft.weave</groupId>
            <artifactId>mule-plugin-weave_2.11</artifactId>
            <version>${mule.version}</version>
            <scope>provided</scope>
        </dependency>
    <dependency>
            <groupId>org.mule.modules</groupId>
            <artifactId>mule-module-ws</artifactId>
            <version>${mule.version}</version>
            <scope>provided</scope>
        </dependency>
    <dependency>
            <groupId>org.mule.modules</groupId>
            <artifactId>mule-module-json</artifactId>
            <version>${mule.version}</version>
            <scope>provided</scope>
        </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>
    </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>

</project>

4.0.0
...

  • 将存储库下载到我的本地计算机
  • “mvn清洁包”
  • 我将工件安装在.m2 maven存储库中
  • 我将插件包括在项目中,我将从中发送工件进行部署
  • 该项目中的“mvn clean package”+“mvn mule mmc rest:deploy”
  • 我想通过在这里提问来摆脱这个奇怪的错误:)
  • 编辑2:

    构建输出-我希望从中在MMC上部署工件的项目

    $ mvn mule-mmc-rest:deploy
    [INFO] Scanning for projects...
    [INFO]
    [INFO] ------------------------------------------------------------------------
    [INFO] Building yeah 6.0.0
    [INFO] ------------------------------------------------------------------------
    [INFO]
    [INFO] >>> mule-mmc-rest-plugin:1.2.2:deploy (default-cli) > compile @ dos >>>
    [INFO]
    [INFO] --- mule-app-maven-plugin:1.2:attach-test-resources (default-attach-test-resources) @ dos ---
    [INFO] attaching test resource C:\a\git\api-flytetyme-pricing\src\main\app
    [INFO]
    [INFO] --- build-helper-maven-plugin:1.7:add-resource (add-resource) @ dos ---
    [INFO]
    [INFO] --- maven-resources-plugin:3.0.1:resources (default-resources) @ dos ---
    [INFO] Using 'UTF-8' encoding to copy filtered resources.
    [INFO] Copying 11 resources
    [INFO] Copying 6 resources
    [INFO] skip non existing resourceDirectory C:\a\git\api-flytetyme-pricing\mappings
    [INFO] Copying 22 resources
    [INFO]
    [INFO] --- mule-app-maven-plugin:1.2:filter-resources (default-filter-resources) @ dos ---
    [INFO]
    [INFO] --- maven-compiler-plugin:3.6.0:compile (default-compile) @ dos ---
    [INFO] Nothing to compile - all classes are up to date
    [INFO]
    [INFO] <<< mule-mmc-rest-plugin:1.2.2:deploy (default-cli) < compile @ dos <<<
    [INFO]
    [INFO] --- mule-mmc-rest-plugin:1.2.2:deploy (default-cli) @ dos ---
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 1.420 s
    [INFO] Finished at: 2016-12-13T10:05:32+00:00
    [INFO] Final Memory: 23M/437M
    [INFO] ------------------------------------------------------------------------
    [ERROR] Failed to execute goal com.github.nicholasastuart:mule-mmc-rest-plugin:1.2.2:deploy (default-cli) on project dos: Execution default-cli of goal com.github.nicholasastuart:mule-mmc-rest-plugin:1.2.2:deploy failed: A required class was missing while executing com.github.nicholasastuart:mule-mmc-rest-plugin:1.2.2:deploy: org/slf4j/impl/StaticLoggerBinder
    [ERROR] -----------------------------------------------------
    [ERROR] realm =    plugin>com.github.nicholasastuart:mule-mmc-rest-plugin:1.2.2
    [ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
    [ERROR] urls[0] = file:/C:/Users/sebastian.xxxxx/.m2/repository/com/github/nicholasastuart/mule-mmc-rest-plugin/1.2.2/mule-mmc-rest-plugin-1.2.2.jar
    [ERROR] urls[1] = file:/C:/Users/sebastian.xxxxx/.m2/repository/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar
    [ERROR] Number of foreign imports: 1
    [ERROR] import: Entry[import  from realm ClassRealm[project>uno:dos:6.0.0, parent: ClassRealm[maven.api, parent: null]]]
    [ERROR]
    [ERROR] -----------------------------------------------------: org.slf4j.impl.StaticLoggerBinder
    [ERROR] -> [Help 1]
    [ERROR]
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR]
    [ERROR] For more information about the errors and possible solutions, please read the following articles:
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginContainerException
    
    $mvn mule mmc rest:部署
    [信息]正在扫描项目。。。
    [信息]
    [信息]------------------------------------------------------------------------
    [信息]建筑耶6.0.0
    [信息]------------------------------------------------------------------------
    [信息]
    [信息]>>>mule mmc rest插件:1.2.2:deploy(默认cli)>compile@dos>>>
    [信息]
    [信息]---mule app maven插件:1.2:附加测试资源(默认附加测试资源)@dos---
    [信息]正在附加测试资源C:\a\git\api Flyteyme pricing\src\main\app
    [信息]
    [信息]---build helper maven插件:1.7:添加资源(添加资源)@dos---
    [信息]
    [信息]---maven资源插件:3.0.1:resources(默认资源)@dos---
    [信息]使用“UTF-8”编码复制筛选的资源。
    [信息]正在复制11个资源
    [信息]正在复制6个资源
    [信息]跳过不存在的资源目录C:\a\git\api flyteyme pricing\mappings
    [信息]正在复制22个资源
    [信息]
    [信息]---mule app maven插件:1.2:过滤资源(默认过滤资源)@dos---
    [信息]
    [信息]---maven编译器插件:3.6.0:compile(默认编译)@dos---
    [信息]无需编译-所有类都是最新的
    [信息]
    [信息]
    
    org.slf4j
    slf4j-log4j12
    1.5.0
    
    依赖项是正确的。我认为您应该清理项目并重新生成。

    编辑:

    考虑到新元素,请尝试以下操作:

    slf4j api和slf4j-log4j12使用相同的版本(目前您使用的是1.7.21和1.5.0=>最新版本,目前是1.7.21)

    您的插件没有在其pom.xml中指定slf4j依赖项。可能此插件的依赖项没有正确提取。尝试:

    <plugin>
        <groupId>com.github.nicholasastuart</groupId>
        <artifactId>mule-mmc-rest-plugin</artifactId>
        <version>1.2.2</version>
        <dependencies>
          <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.21</version>
          </dependency>
       </dependencies>
       ...
       ...
    </plugin>
    
    
    com.github.nicholasastuart
    mule mmc rest插件
    1.2.2
    org.slf4j
    slf4j api
    1.7.21
    ...
    ...
    
    原始答复:

    您正在使用SL4J,可能缺少SL4J API依赖项:

    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>1.7.21</version> <!-- Or a property: ${sl4j-api.version} -->
    </dependency>
    
    
    org.slf4j
    slf4j api
    1.7.21 
    
    如果您的项目依赖于SL4J,您将需要太多的依赖项:

    • SL4J API
    • SL4J绑定,如您已经使用的绑定

    在这个插件经历了几次起伏之后,我找到了让它工作的方法。因此,我们只需在项目中通过粘贴以下脚本调用插件:

        <plugin>
           <groupId>xxxxxxxx/groupId>
       <artifactId>xxxxxxxx</artifactId>
       <version>1.0.0</version>
       <dependencies>
          <dependency>
             <groupId>com.googlecode.slf4j-maven-plugin-log</groupId>
             <artifactId>slf4j-maven-plugin-log</artifactId>
             <version>1.0.0</version>
          </dependency>     
          <dependency>
             <groupId>org.codehaus.jackson</groupId>
             <artifactId>jackson-mapper-asl</artifactId>
             <version>1.9.13</version>
          </dependency>
          <dependency>
             <groupId>org.apache.cxf</groupId>
             <artifactId>cxf-rt-frontend-jaxrs</artifactId>
             <version>2.7.7</version>
          </dependency>
       </dependencies>
       <executions>
          <execution>
             <id>mule-deploy</id>
             <phase>install</phase>
             <goals>
                <goal>deploy</goal>
             </goals>
             <configuration>
                <muleApiUrl>${muleApiUrl}</muleApiUrl>
                <username>${username}</username>
                <password>${password}</password>
                <appDirectory>${project.basedir}/src/main/app</appDirectory>
                <finalName>${project.artifactId}-${project.version}</finalName>
                <version>${version}</version>
                <name>${name}</name>
                <deploymentName>${deploymentName}</deploymentName>
                <serverGroup>${serverGroup}</serverGroup>
             </configuration>
          </execution>
       </executions>
    </plugin>
    
    
    xxxxxxxx/组ID>
    xxxxxxxx
    1.0.0
    com.googlecode.slf4j-maven-plugin-log
    slf4j maven插件日志
    1.0.0
    org.codehaus.jackson
    杰克逊地图绘制者
    1.9.13
    org.apache.cxf
    cxf rt前端jaxrs
    2.7.7
    骡子部署
    安装
    部署
    ${muleApiUrl}
    ${username}
    ${password}
    ${project.basedir}/src/main/app
    ${project.artifactId}-${project.version}
    ${version}
    ${name}
    ${deploymentName}
    ${serverGroup}
    
    嗨,罗密欧,我已经做了两次以上了
    mvn clean package
    但仍然给我这个错误。我以前在使用eclipse时也遇到过类似的问题。我的意思是使用elicpe来清理并生成非mvn。首先请尝试“下面选择的项目清理清理项目”。第二次尝试“项目生成项目/全部”,或者如果选择“自动生成”,请稍候.我只能和你分享这些。如果你还有问题,我很抱歉不能帮你解决。罗密欧,别担心。非常感谢你的帮助,是我的错。很抱歉我正在使用anypoint studio构建我的项目,但达到这一点,我只需打开一个终端并使用maven命令来构建clean和package。所以这并没有给我一个答案,仍然是一样的。我已尝试包含所有sl4j依赖项,但仍然抛出该错误:(请查看我对您的问题的评论,您的pom.xml和maven构建日志将对您有所帮助。嗨,Pierre B,请查看我在帖子上的评论。干杯。嗨,Pierre,谢谢您:尝试过了,但不起作用。我将编辑我的帖子,我将从两者(插件和项目)粘贴依赖关系树)再一次…正如你所看到的。在我的插件依赖树中,我可以看到slf4j api的版本是1.6.1。所以我将在我的项目中使用相同的版本。[INFO]+-com.googlecode.slf4j maven插件日志:slf4j maven插件日志:jar:1.0.0:compile[INFO]| \-org.slf4j:slf4j api:jar:1.6.1:compileIt看起来你的问题已经解决了,太好了!你能自己发布解决方案并将其标记为已接受吗?这可能会帮助将来有相同问题的人。我的问题在那一点上没有解决,因为插件缺少更多的依赖项,我按照与你相同的模式添加了这些依赖项明天上班的时候,我会发布整个solu
    <plugin>
        <groupId>com.github.nicholasastuart</groupId>
        <artifactId>mule-mmc-rest-plugin</artifactId>
        <version>1.2.2</version>
        <dependencies>
          <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.21</version>
          </dependency>
       </dependencies>
       ...
       ...
    </plugin>
    
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>1.7.21</version> <!-- Or a property: ${sl4j-api.version} -->
    </dependency>
    
        <plugin>
           <groupId>xxxxxxxx/groupId>
       <artifactId>xxxxxxxx</artifactId>
       <version>1.0.0</version>
       <dependencies>
          <dependency>
             <groupId>com.googlecode.slf4j-maven-plugin-log</groupId>
             <artifactId>slf4j-maven-plugin-log</artifactId>
             <version>1.0.0</version>
          </dependency>     
          <dependency>
             <groupId>org.codehaus.jackson</groupId>
             <artifactId>jackson-mapper-asl</artifactId>
             <version>1.9.13</version>
          </dependency>
          <dependency>
             <groupId>org.apache.cxf</groupId>
             <artifactId>cxf-rt-frontend-jaxrs</artifactId>
             <version>2.7.7</version>
          </dependency>
       </dependencies>
       <executions>
          <execution>
             <id>mule-deploy</id>
             <phase>install</phase>
             <goals>
                <goal>deploy</goal>
             </goals>
             <configuration>
                <muleApiUrl>${muleApiUrl}</muleApiUrl>
                <username>${username}</username>
                <password>${password}</password>
                <appDirectory>${project.basedir}/src/main/app</appDirectory>
                <finalName>${project.artifactId}-${project.version}</finalName>
                <version>${version}</version>
                <name>${name}</name>
                <deploymentName>${deploymentName}</deploymentName>
                <serverGroup>${serverGroup}</serverGroup>
             </configuration>
          </execution>
       </executions>
    </plugin>