1. org.apache.solr.client.solrj.impl.HttpSolrServer 修改成:org.apache.solr.client.solrj.impl.HttpSolrClient 2. SolrClient solrClient = new CloudSolrClient(zkHost); new方式在新版已經被廢棄,採用新版鏈式賦值法進行建立對象 SolrClient solrClient = new CloudSolrClient.Builder().withZkHost(Arrays.asList(zkHost.split(","))).build(); 3. solrClient = new ConcurrentUpdateSolrClient(url, queueSize, threadCount); 採用鏈式賦值法 solrClient = new ConcurrentUpdateSolrClient.Builder(url).withQueueSize(queueSize).withThreadCount(threadCount).build(); 4. solrClient = new HttpSolrClient(baseURL); 採用鏈式賦值法 solrClient = new HttpSolrClient.Builder(baseURL).build(); 5. ClusterState clusterState = zkStateReader.getClusterState(); Map<String, Slice> map = clusterState.getActiveSlicesMap(collection); api已經將getActiveSlicesMap廢棄 map = clusterState.getCollection(collection).getActiveSlicesMap(); 6. List<String> collections = zkStateReader.getAllCollections(); api已經將getAllCollections()廢棄掉 Map<String, DocCollection> map = zkStateReader.getClusterState().getCollectionsMap(); 7. Collection<Slice> slices = clusterState.getSlices(Collection); api已經將getSlices(collection)廢棄,採用更加方便、安全的中間類DocCollection DocCollection docCollection = clusterState.getCollection(collection); Collection<Slice> slices = docCollection.getActiveSlices(); 8. CollectionAdminRequest.Create req = new CollectionAdminRequest.Create(); req.setCollectionName(name); req.setNumShards(numShards); req.setConfigName(cluster); req.setCreateNodeSet(getNodeSet(cluster)); req.setReplicationFactor(numReplicas); 修改成鏈式賦值法 CollectionAdminRequest.Create req = CollectionAdminRequest.createCollection(name, cluster, numShards, numReplicas); 9. CollectionAdminRequest.Delete req = new CollectionAdminRequest.Delete(); api已將這種建立方式廢棄 CollectionAdminRequest.Delete req = CollectionAdminRequest.deleteCollection(name); 10. CollectionAdminRequest.CreateAlias req = new CollectionAdminRequest.CreateAlias(); api已經將這種建立方式廢棄 CollectionAdminRequest.CreateAlias req = CollectionAdminRequest.createAlias(name, collections); 11. CollectionAdminRequest.DeleteAlias req = new CollectionAdminRequest.deleteAlias(); api已經將這種建立方式廢棄 CollectionAdminRequest.DeleteAlias req = CollectionAdminRequest.deleteAlias(name); 12. SolrInputDocument inputDocument = ClientUtils.toSolrInputDocument(solrDocument); 將SolrDocument 轉換爲 SolrInputDocument 的方法從ClientUtils中移除了.從solr-5.5以後就將此方法移除,代碼中要想使用此相似功能,須要本身添加方法實現 /** * 將SolrDocument轉換爲SolrInputDocument,原底層提供的方法從solr5.5以後被廢棄掉了 * add by liangyongxing * @param solrDocument * @createTime 2017-02-21 * @return */ public static SolrInputDocument toSolrInputDocument(SolrDocument solrDocument) { SolrInputDocument doc = new SolrInputDocument(); for (String name : solrDocument.getFieldNames()) { doc.addField(name, solrDocument.getFieldValue(name)); } return doc; }
以上這個錯誤對於有點經驗的程序員來講都是很easy的問題,就是服務器上的jdk和我們打包程序所使用的jdk版本不一致,很明顯,本地使用的是jdk1.8而服務器上的是jdk1.7,具體能夠經過命令:java -version 進行查看jdk版本。那麼就好辦了,直接下載或者拷貝均可以,將當前環境的jdk升級爲18的便可,這個是很easy的我就不在這裏囉嗦了。html
spring-aop-3.2.13-RELEASE.jar、spring-beans-3.2.13-RELEASE.jar、spring-context-3.2.13-RELEASE.jar、spring-context-support-3.2.13-RELEASE.jar、spring-core-3.2.13-RELEASE.jar、spring-jdbc-3.2.13-RELEASE.jar、spring-orm-3.2.13-RELEASE.jar、spring-tx-3.2.13-RELEASE.jar、spring-web-3.2.13-RELEASE.jar等java