Мой репозиторий не может инициализироваться автоматически при использовании Spring Data JPA

Я пытаюсь добавить Spring Data JPA в мой веб-проект spring-mvc после изучения нескольких учебников. Но я обнаружил, что мой репозиторий не может инициализироваться автоматически, я получил исключение NullPointerException в своем классе обслуживания. Пожалуйста, смотрите мой следующий пример кода:

Мой репозиторий:

<code>public interface SubjectRepository extends JpaRepository<PSubject, String>{
public Page<PSubject> findByType(String title, Pageable pageable);
public Page<PSubject> findByType(String title);
public Page<PSubject> findByMacaddress(String macaddress, Pageable pageable);
public Page<PSubject> findByMacaddress(String macaddress);
public Page<PSubject> findByUri(String uri);
</code>

}

Мой контроллер & # xFF1A;

<code>@Controller
@RequestMapping("/subject")  
public class VPSubjectController
{
....
@RequestMapping("/{id}.htm")
    public ModelAndView detail(@PathVariable String id)
    {
        ModelAndView mav = new ModelAndView("subject/detail");
        PSubject subject = subjectService.get(id);
....
}
}
</code>

Мой сервис & # xFF1A;

<code>@Service("subjectService")
public class SubjectServiceImpl extends VPService implements SubjectService
{

    @Autowired
    private SubjectRepository subjectRepository;
......
@Override
    @Transactional(propagation=Propagation.REQUIRED, readOnly=true)
    public PSubject get(String subject) {
        PSubject subObj = subjectRepository.findOne(subject);
        return subObj;
    }
.....
</code>

Моя конфигурация:

<code><?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:util="http://www.springframework.org/schema/util"
    xmlns:jpa="http://www.springframework.org/schema/data/jpa"
    xsi:schemaLocation="    
           http://www.springframework.org/schema/beans 
           http://www.springframework.org/schema/beans/spring-beans.xsd 
           http://www.springframework.org/schema/context 
           http://www.springframework.org/schema/context/spring-context.xsd 
           http://www.springframework.org/schema/mvc 
           http://www.springframework.org/schema/mvc/spring-mvc.xsd
           http://www.springframework.org/schema/util 
           http://www.springframework.org/schema/util/spring-util-3.0.xsd
           http://www.springframework.org/schema/data/jpa
           http://www.springframework.org/schema/data/jpa/spring-jpa.xsd">
....
<jpa:repositories base-package="com.mypacke.repository"  repository-impl-postfix="Impl" entity-manager-factory-ref="entityManagerFactory" transaction-manager-ref="transactionManager"/>
</code>

....

Я нашел в этой строке subjectRepository.findOne (subject), subjectRepository имеет значение null, Мой вопрос похож на этосообщение

Ответы на вопрос(1)

Ваш ответ на вопрос