把MysqL-connector-java-5.1.29-bin.jar放到〜/ Tools / Solr / example / lib /
1.配置〜/ Tools / Solr / example / solr / collection1 / conf / data-config.xml:
<dataConfig> <dataSource type="JdbcDataSource" driver="com.MysqL.jdbc.Driver" url="jdbc:MysqL://localhost:3306/test" user="root" password="root"/> <document> <entity name="SolrTest" query="select * from SolrTest"> <field column="ID" name="id"/> <field column="Name" name="name"/> <field column="Class" name="class"/> <field column="score" name="score"/> </entity> </document> </dataConfig>
2.Configure~ / Tools / Solr / example / solr / collection1 / conf / solrconfig.xml:
<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler"> <lst name="defaults"> <str name="config">data-config.xml</str> </lst> </requestHandler>
也
<lib dir="../../../dist/" regex="solr-dataimporthandler-\d.*\.jar" /> <lib dir="../../../contrib/dataimporthandler/lib" regex=".*\.jar" />
3.将以下内容添加到〜/ Tools / Solr / example / solr / collection1 / conf / schema.xml:
<field name="id" type="int" indexed="true" stored="true" required="true"/> <field name="name" type="string" indexed="true" stored="true"/> <field name="class" type="string" indexed="true" stored="true" /> <field name="score" type="int" indexed="true" stored="true"/>
然后跑
java -jar start.jar
当我去
http://localhost:8983/solr/#/collection1/dataimport//dataimport
表明
No information available (idle)
当我单击执行按钮时,我收到以下错误消息:
31537 [Thread-15] ERROR org.apache.solr.handler.dataimport.DataImporter – Full Import
Failed:java.lang.RuntimeException: java.lang.RuntimeException:
org.apache.solr.handler.dataimport.DataImportHandlerException: Could
not load driver: com.MysqL.jdbc.Driver Processing Document # 1 at
org.apache.solr.handler.dataimport.DocBuilder.execute(DocBuilder.java:270)
at
org.apache.solr.handler.dataimport.DataImporter.doFullImport(DataImporter.java:411)
at
org.apache.solr.handler.dataimport.DataImporter.runCmd(DataImporter.java:476)
at
org.apache.solr.handler.dataimport.DataImporter$1.run(DataImporter.java:457)
Caused by: java.lang.RuntimeException:
org.apache.solr.handler.dataimport.DataImportHandlerException: Could
not load driver: com.MysqL.jdbc.Driver Processing Document # 1 at
org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:410)
at
org.apache.solr.handler.dataimport.DocBuilder.doFullDump(DocBuilder.java:323)
at
org.apache.solr.handler.dataimport.DocBuilder.execute(DocBuilder.java:231)
… 3 more Caused by:
org.apache.solr.handler.dataimport.DataImportHandlerException: Could
not load driver: com.MysqL.jdbc.Driver Processing Document # 1 at
org.apache.solr.handler.dataimport.DataImportHandlerException.wrapAndThrow(DataImportHandlerException.java:71)
at
org.apache.solr.handler.dataimport.JdbcDataSource.createConnectionFactory(JdbcDataSource.java:116)
at
org.apache.solr.handler.dataimport.JdbcDataSource.init(JdbcDataSource.java:64)
at
org.apache.solr.handler.dataimport.DataImporter.getDataSourceInstance(DataImporter.java:383)
at
org.apache.solr.handler.dataimport.ContextImpl.getDataSource(ContextImpl.java:99)
at
org.apache.solr.handler.dataimport.sqlEntityProcessor.init(sqlEntityProcessor.java:53)
at
org.apache.solr.handler.dataimport.EntityProcessorWrapper.init(EntityProcessorWrapper.java:74)
at
org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:427)
at
org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:408)
… 5 more Caused by: java.lang.ClassNotFoundException: Unable to
load com.MysqL.jdbc.Driver or
org.apache.solr.handler.dataimport.com.MysqL.jdbc.Driver at
org.apache.solr.handler.dataimport.DocBuilder.loadClass(DocBuilder.java:916)
at
org.apache.solr.handler.dataimport.JdbcDataSource.createConnectionFactory(JdbcDataSource.java:114)
… 12 more Caused by: org.apache.solr.common.SolrException: Error
loading class ‘com.MysqL.jdbc.Driver’ at
org.apache.solr.core.SolrResourceLoader.findClass(SolrResourceLoader.java:470)
at
org.apache.solr.core.SolrResourceLoader.findClass(SolrResourceLoader.java:401)
at
org.apache.solr.handler.dataimport.DocBuilder.loadClass(DocBuilder.java:906)
… 13 more Caused by: java.lang.ClassNotFoundException:
com.MysqL.jdbc.Driver at
java.net.URLClassLoader$1.run(URLClassLoader.java:366) at
java.net.URLClassLoader$1.run(URLClassLoader.java:355) at
java.security.AccessController.doPrivileged(Native Method) at
java.net.URLClassLoader.findClass(URLClassLoader.java:354) at
java.lang.ClassLoader.loadClass(ClassLoader.java:423) at
java.net.FactoryURLClassLoader.loadClass(URLClassLoader.java:789) at
java.lang.ClassLoader.loadClass(ClassLoader.java:356) at
java.lang.Class.forName0(Native Method) at
java.lang.Class.forName(Class.java:264) at
org.apache.solr.core.SolrResourceLoader.findClass(SolrResourceLoader.java:454)
… 15 more
怎么解决这个?