相关疑难解决方法(0)

SLF4J:无法加载类"org.slf4j.impl.StaticLoggerBinder"

我的应用程序将部署在tcServer和WebSphere 6.1上.此应用程序使用ehCache,因此需要slf4j作为依赖项.结果我将slf4j-api.jar(1.6)jar添加到我的war文件包中.

该应用程序在tcServer中正常工作,但以下错误除外:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Run Code Online (Sandbox Code Playgroud)

但是,当我在WebSphere中部署时,我得到了一个java.lang.NoClassDefFoundError: org.slf4j.impl.StaticLoggerBinder.

我检查了两个应用程序服务器的类路径,没有其他的slf4j jar.

有没有人有任何想法可能会发生在这里?

java websphere slf4j

547
推荐指数
17
解决办法
78万
查看次数

无法找到或加载主类org.gradle.wrapper.GradleWrapperMain

我通过删除本地目录等清洗整个项目~/.gradle,~/.m2 ~./android~/workspace/project/.gradle和艇员选拔File -> Invalidate Caches / Restart...Android Studio中.现在执行命令./gradlew会导致以下输出:

usr$ ./gradlew tasks
Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain
Run Code Online (Sandbox Code Playgroud)

不用说,我删了太多,问题是如何再次修复?你有任何想法如何解决这个问题?

gradle gradlew android-studio android-gradle-plugin

140
推荐指数
12
解决办法
12万
查看次数

Maven + SLF4J:使用需要两个不同SLF4J版本的两个不同依赖项时版本冲突

我有一个独立使用两个依赖项的项目:BoneCP和Hibernate.但是由于SLF4J及其版本冲突它不起作用,因为BoneCP需要SLF4J 1.5而Hibernate需要SLF4j 1.6.如您所知,不可能在pom.xml中重要两个不同版本的相同依赖项.那么我该怎么办才能解决这个惊人的SLF4J副作用?

我得到的错误是臭名昭着的:

SLF4J: The requested version 1.5.10 by your slf4j binding is not compatible with [1.6]
SLF4J: See http://www.slf4j.org/codes.html#version_mismatch for further details.
Run Code Online (Sandbox Code Playgroud)

我需要添加它,但不允许使用两个不同版本的相同依赖:

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.5.10</version>
<scope>provided</scope>
</dependency>   

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.2</version>
<scope>provided</scope>
</dependency>   
Run Code Online (Sandbox Code Playgroud)

Maven依赖树:

[INFO] [dependency:tree {execution: default-cli}]
[INFO] org.mentawai:menta:war:1.0.5-SNAPSHOT
[INFO] +- javax.servlet.jsp:jsp-api:jar:2.0:provided
[INFO] +- javax.servlet:servlet-api:jar:2.5:provided
[INFO] +- javax.activation:activation:jar:1.1:compile
[INFO] +- javax.mail:mail:jar:1.4:compile
[INFO] +- javax.persistence:persistence-api:jar:1.0:compile
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.5.10:compile
[INFO] |  +- org.slf4j:slf4j-api:jar:1.5.10:compile
[INFO] |  \- log4j:log4j:jar:1.2.14:compile
[INFO] +- org.hibernate:hibernate-core:jar:3.6.7.Final:compile
[INFO] |  +- antlr:antlr:jar:2.7.6:compile
[INFO] |  +- …
Run Code Online (Sandbox Code Playgroud)

java dependencies hibernate slf4j maven

22
推荐指数
2
解决办法
5万
查看次数

使用Maven构建时slf4j版本冲突

我意识到我的一个项目使用slf4j 1.5.8而Hibernate使用slf4j 1.6.在使用Maven构建时,它会下载两个jar,但我想使用的是1.5.8的类文件.所以,当我运行程序时,我得到以下错误:

SLF4J: The requested version 1.5.8 by your slf4j binding is not compatible with [1.6]
Run Code Online (Sandbox Code Playgroud)

pom.xml我已经把

<dependencyManagement>    
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.6.1</version>
    </dependency>
</dependencyManagement>
Run Code Online (Sandbox Code Playgroud)

1.5.8是依赖的一部分,所以它是自己下载的.

java slf4j maven

18
推荐指数
2
解决办法
3万
查看次数

如何摆脱“类路径包含多个 SLF4J 绑定”警告?

这或多或少是一个“常见”问题,但是,我还没有找到一个好的答案。所以,再次警告:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/eualin/.m2/repository/org/slf4j/slf4j-jcl/1.6.0/slf4j-jcl-1.6.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/eualin/.m2/repository/org/slf4j/slf4j-log4j12/1.5.11/slf4j-log4j12-1.5.11.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
Run Code Online (Sandbox Code Playgroud)

这里有两个可能的问题解决方案[1] [2]

假设它们都为我工作,显然,它们只是黑客,我不确定我是否应该依赖它们中的任何一个。你会推荐我什么?请记住,在终端中不会出现警告;仅当我通过 IntelliJIDEA 运行应用程序时。

任何建议都将受到高度赞赏。

java warnings slf4j

5
推荐指数
2
解决办法
2万
查看次数

spring web development - 禁用静态内容缓存

我正在用 Spring 开发一个 angularjs 应用程序。

我经常不得不更改我的 html/javascript 文件,我注意到 spring 正在缓存静态内容。我怎样才能禁用它?

我已经尝试过这个...

@Configuration
@AutoConfigureAfter(DispatcherServletAutoConfiguration.class)
class WebMvcConfig extends WebMvcAutoConfiguration.WebMvcAutoConfigurationAdapter {

    @Autowired
    private Environment env;

    @Bean
    public ResourceUrlEncodingFilter resourceUrlEncodingFilter() {
        return new ResourceUrlEncodingFilter();
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        boolean devMode = this.env.acceptsProfiles("dev");
        //boolean useResourceCache = !devMode;
        boolean useResourceCache = false;
        Integer cachePeriod = devMode ? 0 : null;

        registry.addResourceHandler("/public/**")
                .addResourceLocations("/public/", "classpath:/public/")
                .setCachePeriod(cachePeriod)
                .resourceChain(useResourceCache)
                .addResolver(new GzipResourceResolver())
                .addResolver(new VersionResourceResolver().addContentVersionStrategy("/**"))
                .addTransformer(new AppCacheManifestTransformer());
    }

}
Run Code Online (Sandbox Code Playgroud)

然后 ...

WebContentInterceptor webContentInterceptor;
public @Bean WebContentInterceptor webContentInterceptor () { …
Run Code Online (Sandbox Code Playgroud)

java configuration spring spring-boot

3
推荐指数
1
解决办法
1万
查看次数