package com.Test.springboot;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.ComponentScan;
@SpringBootApplication
@ComponentScan({"com.Test.springboot"})
public class SpringBoot1Application {
public static void main(String[] args) {
SpringApplication.run(SpringBoot1Application.class, args);
}
}
Controller Class
package com.Test.springboot;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import com.Test.springboot.model.Student;
import com.Test.springboot.model.StudentDao;
@Controller
public class StudentController {
@Autowired
private StudentDao studentDao;
@RequestMapping("/")
public String homePage() {
return "home";
}
StudentDao
@Repository
public interface StudentDao {
public Student addStudent(Student student);
public Student getStudent(long id);
public List<Student> getAllStudents();
public String deleteStudent();
}
If we change the stereotype(Repository) annotation to implementation class it's working fine. but Interface level throwing an error(org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.vitechinc.springboot.model.StudentDao' available:)
Try adding below code as a maven dependancy in the
pom.xmlfile:I got the same issue and after installing this dependency now its working,