Dubbo remote call solr problem

Dubbo remote call solr problem

Using Dubbo to call the solr query of the server remotely, there is a return value, but the mapping to the bean is null. Server-side local tests, return values are normally mapped to beans

@Service
public class ItemSearchServiceImpl implements ItemSearchService {
	
	@Autowired
	private SolrTemplate solrTemplate;


	@Override
	public Map search(Map searchMap) {
		Map map = new HashMap();
		Query query = new SimpleQuery();
		System.out.println(searchMap.get("keywords"));
		Criteria criteria = new Criteria("item_keywords").is(searchMap.get("keywords"));
		query.addCriteria(criteria );
		ScoredPage<TbItem> page = solrTemplate.queryForPage(query,TbItem.class);
		for(TbItem item:page.getContent()) {
			System.out.println(item.getTitle());
		}
		map.put("rows", page.getContent());
		return map;
	}

}

Controller remote call:

@RestController
@RequestMapping("/itemSearch")
public class ItemSearchController {
	
	@Reference
	private ItemSearchService itemSearchService;
	
	@RequestMapping("/search")
	public Map search(@RequestBody Map searchMap) {
		return itemSearchService.search(searchMap);
	}

}

The console prints as follows:

August 01, 2019 8:58:44 Afternoon org.apache.catalina.core.ApplicationContext log
//Information: No Spring Web Application Initializer types detected on classpath
//August 01, 2019: 58:45 p.m. org. apache. catalina. core. Application Context log
//Information: Initializing Spring root Web Application Context
log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
//August 01, 2019 8:58:59 p.m. org.apache.coyote.AbstractProtocol start
//Information: Starting ProtocolHandler ["http-bio-9004"]
//association
null
null
null
null
null
null
null
null
null
null

Then the local test call

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations="classpath:spring/applicationContext-service.xml") 
public class TestTest {
	
	@Autowired
	private ItemSearchServiceImpl item;

	@Test
	public void test1() {
		Map searchMap = new HashMap();
		searchMap.put("keywords", "association");
		item.search(searchMap);
	}
}

The console prints as follows:

log4j:WARN No appenders could be found for logger (org.springframework.test.context.junit4.SpringJUnit4ClassRunner).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
association
 Lenovo A360e Rongxuebai Telecom 3G Mobile Phone
 Lenovo A360e Deep Black Telecom 3G Mobile Phone
 Lenovo A916 Deep Black Unicom 4G Mobile Dual Card
 Lenovo A916 White Unicom 4G Mobile Dual Card
 Lenovo A396 White Unicom 3G Mobile Phone
 Lenovo A690e White Telecom 4G Mobile Dual Card
 Lenovo A690e Black Telecom 4G Mobile Dual Card
 Lenovo MA388 Senior Mobile Star Night Mobile Unicom 2G Mobile Dual Card Dual Wait
 Lenovo P780 Extreme Speed Edition Deep Black Unicom 3G Mobile Dual Card Dual Wait
 Lenovo S820e Red Telecom 3G Mobile Phone Dual Card Dual Wait

Tags: Mobile log4j Apache Spring

Posted on Sat, 12 Oct 2019 11:29:57 -0700 by l053r