代码之家  ›  专栏  ›  技术社区  ›  notacorn

如何在运行mvn包时阻止logback classic在m2存储库中再次出现

  •  0
  • notacorn  · 技术社区  · 5 年前

    SLF4J: Class path contains multiple SLF4J bindings.
    SLF4J: Found binding in [jar:file:/C:.../repository/org/slf4j/slf4j-nop/1.7.30/slf4j-nop-1.7.30.jar!/org/slf4j/impl/StaticLoggerBinder.class]
    SLF4J: Found binding in [jar:file:/C:.../repository/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
    SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
    SLF4J: Actual binding is of type [org.slf4j.helpers.NOPLoggerFactory]
    

    因为我想保留Lombok附带的slf4j,所以我尝试删除了这个文件夹 logback-classic/1.2.3 . 但每次我跑的时候它总是回来 mvn package

    pom.xml文件

    <project>
        <modelVersion>4.0.0</modelVersion>
        <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>2.3.0.RELEASE</version>
            <relativePath/>
        </parent>
        <groupId>**********</groupId>
        <artifactId>rest</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <name>rest</name>
    
        <properties>
            <java.version>1.8</java.version>
            <endpoints.project.id>**********</endpoints.project.id>
        </properties>
    
        <dependencies>
            <dependency>
                <groupId>com.google.endpoints</groupId>
                <artifactId>endpoints-framework</artifactId>
                <version>2.2.1</version>
            </dependency>
            <!-- [START api_management] -->
            <dependency>
                <groupId>com.google.endpoints</groupId>
                <artifactId>endpoints-management-control-appengine-all</artifactId>
                <version>1.0.12</version>
            </dependency>
            <!-- [END api_management] -->
            <dependency>
                <groupId>com.google.appengine</groupId>
                <artifactId>appengine-api-1.0-sdk</artifactId>
                <version>1.9.80</version>
            </dependency>
            <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>javax.servlet-api</artifactId>
                <version>3.1.0</version>
                <type>jar</type>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>javax.inject</groupId>
                <artifactId>javax.inject</artifactId>
                <version>1</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter</artifactId>
            </dependency>
    
            <dependency>
                <groupId>org.projectlombok</groupId>
                <artifactId>lombok</artifactId>
                <optional>true</optional>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-test</artifactId>
                <scope>test</scope>
                <exclusions>
                    <exclusion>
                        <groupId>org.junit.vintage</groupId>
                        <artifactId>junit-vintage-engine</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
        </dependencies>
    
        <build>
            <plugins>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                </plugin>
                <plugin>
                    <groupId>com.google.cloud.tools</groupId>
                    <artifactId>appengine-maven-plugin</artifactId>
                    <version>2.2.0</version>
                    <configuration>
                        <!-- deploy configuration -->
                        <projectId>GCLOUD_CONFIG</projectId>
                        <version>GCLOUD_CONFIG</version>
                    </configuration>
                </plugin>
                <!-- [START endpoints_plugin] -->
                <plugin>
                    <groupId>com.google.cloud.tools</groupId>
                    <artifactId>endpoints-framework-maven-plugin</artifactId>
                    <version>2.0.1</version>
                    <configuration>
                        <!-- plugin configuration -->
                        <hostname>${endpoints.project.id}.appspot.com</hostname>
                    </configuration>
                </plugin>
                <!-- [END endpoints_plugin] -->
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>versions-maven-plugin</artifactId>
                    <version>2.7</version>
                    <executions>
                        <execution>
                            <phase>compile</phase>
                            <goals>
                                <goal>display-dependency-updates</goal>
                                <goal>display-plugin-updates</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    
    </project>
    

    0 回复  |  直到 5 年前
        1
  •  1
  •   khmarbaise    5 年前

    我在这里回答是因为评论很简短:(还没有最终答案):

    spring-boot-starter ... 或者更准确 弹簧启动机 依赖于 spring-boot-starter-logging 它依赖于 logback-classic 哪个是 default for spring-boot .

    而且我不明白 slf4j in lombok project

    还有一件事,第一种依赖 endpoints-framework contains the reference to slf4j-nop 这在我看来是错误的。

    除了以上所有配置版本之外,maven插件和绑定它到 compile 阶段没有意义,这使你的建设非常缓慢。。。。