estou configurando um projeto usando o Spring boot para ioc e Data-Jpa junto com JSF contudo estou com um probleminha no @Autowired
meu DAO não esta carregando.
Alguém sabe fazer essa configuração e onde posso estar errando?
Segue minha configuração:
Classe ApplicationConfig
@SpringBootApplication
@ComponentScan
public class ApplicationConfig extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(ApplicationConfig.class);
}
@Bean
public ServletRegistrationBean servletRegistrationBean() {
FacesServlet servlet = new FacesServlet();
ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(servlet, "*.xhtml");
return servletRegistrationBean;
}
}
Classe loginMbController
@ManagedBean(name = "login")
@Component
public class LoginMBController {
@Autowired
private CustomerDao customerDao;
public void test() {
System.out.println("Hello");
System.out.println(customerDao);
}
}
O customerDao
public interface CustomerDao extends JpaRepository<Customer, Long>{
}
O application.properties
# Show or not log for each sql query
spring.jpa.show-sql = true
# Hibernate ddl auto (create, create-drop, update)
spring.jpa.hibernate.ddl-auto = update
# Datasource
spring.datasource.jndi-name=java:jboss/datasources/mysqlDS
Login.xhtml
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<h:head></h:head>
<h:body>
<H2>
<h:outputText value="Login Page" />
</H2>
<h:form>
<p:button value="ok" onclick="#{login.test()}" />
</h:form>
</h:body>
</html>
e meu web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
id="WebApp_ID" version="3.1">
<display-name>CarlosSnackBar</display-name>
<welcome-file-list>
<welcome-file>login.xhtml</welcome-file>
</welcome-file-list>
</web-app>
quando eu clico no botão "ok" no console aparece "hello null"