启动 Apache Solr Admin (Win7),在配置 Solr DataImportHandler 以使用 JDBC SQLServerDriver 连接到 SQL Server 后,会产生以下错误。MS Sql JDBC 连接器 sqljdbc4.jar 放在 Solr 的 bin 和 lib 文件夹中。
org.apache.solr.servlet.SolrDispatchFilter init
SEVERE: Could not start SOLR. Check solr/home property
org.apache.solr.common.SolrException: FATAL: Could not create importer. DataImporter config invalid
...
Caused by: org.apache.solr.handler.dataimport.DataImportHandlerException: Exception occurred while initializing context
at ...
Caused by: org.xml.sax.SAXParseException: Content is not allowed in prolog...
solrconfig.xml 有:
<requestHandler name="dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">
<lst name="defaults">
<str name="config">data-config.xml</str>
</lst>
</requestHandler>
数据配置.xml 是:
<dataConfig>
<dataSource type="JdbcDataSource" name="hy"
driver="com.microsoft.sqlserver.jdbc.SQLServerDriver"
url="jdbc:sqlserver://localhost;databaseName=test;responseBuffering=adaptive;"
user="test"
password="test"
readOnly="true"/>
<document name="listings">
<entity name="listings" dataSource="hy" pk="ListID"
query = "SELECT ListID, Description, PostDate FROM Listings"
transformer="DateFormatTransformer">
<field column="PostDate" name="PostDate" dateTimeFormat="yyyy-MM-dd" />
</entity>
</document>
</dataConfig>
任何建议将被认真考虑。