I am trying to create an application following example code in the book "Spring Data" by Petri Kainulainen. I have a service RepositoryContactService package com.packtpub.springdata.jpa.service;
@Service("service")
public class RepositoryContactService implements ContactService {
My ApplicationContext class sets the package of the service for scanning
@Configuration
@ComponentScan(basePackages = { "com.packtpub.springdata.jpa.service" })
@EnableTransactionManagement
@EnableWebMvc
@EnableJpaRepositories("com.packtpub.springdata.jpa.repository")
@PropertySource("classpath:application.properties")
public class ApplicationContext extends WebMvcConfigurerAdapter {
I am running class Test with declaration
@Autowired
private static RepositoryContactService service;
and code in the main method
Contact contact = new Contact("handro1104@gmail.com", "handro");
service.save(contact);
The problem is that the line "service.save(contact);" is giving me service null.