3

当我运行 flyway maven 插件时,它最初会下载 1.5.6 版本的 slf4j jar:

[INFO] ------------------------------------------------------------------------
Downloading: http://repo1.maven.org/maven2/org/slf4j/slf4j-jdk14/1.5.6/slf4j-jdk14-1.5.6.pom
Downloaded: http://repo1.maven.org/maven2/org/slf4j/slf4j-jdk14/1.5.6/slf4j-jdk14-1.5.6.pom (2 KB at 21.3 KB/sec)
Downloading: http://repo1.maven.org/maven2/org/slf4j/slf4j-parent/1.5.6/slf4j-parent-1.5.6.pom
Downloaded: http://repo1.maven.org/maven2/org/slf4j/slf4j-parent/1.5.6/slf4j-parent-1.5.6.pom (8 KB at 154.7 KB/sec)

这对我的 Spring Web 应用程序造成了严重破坏,因为我在那里使用 1.7.2 版的 slf4j,当我重新启动它时它会感到困惑。

我怎样才能防止这种情况?我尝试向我的 pom.xml 添加排除项:

<groupId>com.googlecode.flyway</groupId>
                <artifactId>flyway-maven-plugin</artifactId>
                <version>2.0.3</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.slf4j</groupId>
                        <artifactId>slf4j-log4j12</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>org.slf4j</groupId>
                        <artifactId>slf4j-api</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>org.slf4j</groupId>
                        <artifactId>jcl-over-slf4j</artifactId>
                    </exclusion>
                </exclusions>

但这仍然会发生。

更新:当我使用 Intellij 12 构建时,这导致以下错误:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/tom/Library/Caches/IntelliJIdea12/tomcat/Unnamed_incrowdnow/work/Catalina/localhost/_/WEB-INF/lib/slf4j-jdk14-1.5.6.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/tom/Library/Caches/IntelliJIdea12/tomcat/Unnamed_incrowdnow/work/Catalina/localhost/_/WEB-INF/lib/slf4j-simple-1.7.2.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.impl.JDK14LoggerFactory]
SLF4J: The requested version 1.5.6 by your slf4j binding is not compatible with [1.6, 1.7]
SLF4J: See http://www.slf4j.org/codes.html#version_mismatch for further details.

更新: mvn 依赖的输出:tree -Dverbose -Dincludes=org.slf4j

[INFO] \- com.googlecode.flyway:flyway-maven-plugin:jar:2.0.3:compile
[INFO]    \- org.apache.maven:maven-core:jar:2.2.1:compile
[INFO]       +- org.apache.maven.wagon:wagon-webdav-jackrabbit:jar:1.0-beta-6:runtime
[INFO]       |  +- org.apache.jackrabbit:jackrabbit-webdav:jar:1.5.0:runtime
[INFO]       |  |  \- (org.slf4j:slf4j-api:jar:1.5.3:runtime - omitted for conflict with 1.7.2)
[INFO]       |  \- org.slf4j:slf4j-nop:jar:1.5.3:runtime
[INFO]       |     \- (org.slf4j:slf4j-api:jar:1.5.3:runtime - omitted for conflict with 1.7.2)
[INFO]       +- org.slf4j:slf4j-jdk14:jar:1.5.6:runtime
[INFO]       |  \- (org.slf4j:slf4j-api:jar:1.5.6:runtime - omitted for conflict with 1.7.2)
[INFO]       \- (org.slf4j:jcl-over-slf4j:jar:1.5.6:runtime - omitted for conflict with 1.7.2)

TIA,

汤姆

4

3 回答 3

1

Flyway Maven 插件 2.0.3 和 Flyway Core 2.0.3 都不依赖于 slf4j。检查您的依赖项。问题一定来自其他地方。

于 2013-01-04T15:04:21.337 回答
0

我有类似的问题,并通过使用 flyway-core 依赖而不是 flyway-maven-plugin 依赖来解决它。

于 2015-06-17T08:57:27.160 回答
0

FLyway下载slf4j依赖,如果你的应用使用1.7.x或1.6.x版本,那么你会遇到这个问题,因为flyway下载的是1.5.3版本的slf4j-nop和1.5.6版本的slf4j-jdk14。在 Eclipse 中,您可以在 pom.xml 的依赖层次结构下看到这一点

为了摆脱这个,添加以下所有exclusiions,你就完成了

        <exclusions>
            <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>log4j-over-slf4j</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>jcl-over-slf4j</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-nop</artifactId>
            </exclusion>    
            <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-jdk14</artifactId>
            </exclusion>                
        </exclusions>    
于 2015-06-27T19:21:22.857 回答