我有一个这样的类(它是 Eclipse 中的一个 java 类,在一个 Maven 项目下):
public class SolrJ
{
public static void main( String[] args )
{
String url = "http://localhost:8983/solr";
try {
SolrServer server = new CommonsHttpSolrServer(url);
server.deleteByQuery( "*:*" );
} catch (MalformedURLException ex) {
ex.printStackTrace();
} catch (SolrServerException ex) {
ex.printStackTrace();
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
运行这个类后,我得到了以下异常:
Exception in thread "main" java.lang.IllegalAccessError: tried to access field org.slf4j.impl.StaticLoggerBinder.SINGLETON from class org.slf4j.LoggerFactory
at org.slf4j.LoggerFactory.staticInitialize(LoggerFactory.java:83)
at org.slf4j.LoggerFactory.<clinit>(LoggerFactory.java:73)
at org.apache.solr.client.solrj.impl.CommonsHttpSolrServer.<clinit>(CommonsHttpSolrServer.java:77)
at ultimo.solrJ.SolrJ.main(SolrJ.java:19)
我的 pom.xml 看起来像这样:
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<artifactId>solr-solrj</artifactId>
<groupId>org.apache.solr</groupId>
<version>1.4.0</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<artifactId>solr-core</artifactId>
<groupId>org.apache.solr</groupId>
<version>1.4.0</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.5.6</version>
</dependency>
有人可以帮忙解决我的问题吗?我已经通过 Internet 搜索,但找不到任何方法来解决我的问题。