Support
Quality
Security
License
Reuse
kandi has reviewed mybatis-3 and discovered the below as its top functions. This is intended to give you an instant insight into mybatis-3 implemented functionality, and help decide if they suit your requirements.
Get all kandi verified functions for this library.
Get all kandi verified functions for this library.
MyBatis SQL mapper framework for Java
QUESTION
Error required a bean of type 'XXX' that could not be found
Asked 2022-Apr-07 at 10:25I'm updating a spring boot project by adding a page called news and it has error below.
Field newsService in com.lrs.admin.controller.NewsController required a bean of type 'com.lrs.admin.service.INewsService' that could not be found.
The code is like below: Application.java
@MapperScan("com.lrs.admin.dao")
@ServletComponentScan
@SpringBootApplication
public class Application extends SpringBootServletInitializer implements EmbeddedServletContainerCustomizer{
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
NewController.java
@Controller
@RequestMapping("/news")
public class NewsController extends BaseController {
private final static String qxurl="news/list";
@Autowired
private INewsService newsService;
INewsService.java
package com.lrs.admin.service;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpSession;
import org.springframework.stereotype.Componnt;
import com.lrs.admin.util.ParameterMap;
@Component
public interface INewsService {
public List<ParameterMap> list();
public Map<String,Object> getNews(ParameterMap pm);
public Map<String,Object> edit(ParameterMap pm);
public Map<String,Object> add(ParameterMap pm,HttpSession session);
public Map<String,Object> del(String newsId);
}
NewsService.java
public class NewsService implements INewsService {
@Autowired
private NewsDao newsDao;
NewsDao.java
public interface NewsDao {
public List<ParameterMap> list();
public List<ParameterMap> getAllNewsById(ParameterMap pm);
public ParameterMap getNewsById(ParameterMap pm);
public void updateNews(ParameterMap pm);
public void addNews(ParameterMap pm);
public void delNews(String roleId);
// public void delUserRole(String roleId);
}
NewsMapper.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.lrs.admin.dao.NewsDao">
</mapper>
I just create those files and not implement any method yet.Is this the reason? Any help?Thx.
ANSWER
Answered 2022-Apr-07 at 09:59you should annotate @Service
on the class which implements the interface instead of the interface itself. That is, annotate the NewsService
with @Service
, and you can remove the @Component
tag from INewsService
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
No vulnerabilities reported
Save this library and start creating your kit
See Similar Libraries in
Save this library and start creating your kit
Open Weaver – Develop Applications Faster with Open Source