I try to have a project with Spring Boot and JSF. I add a servlet mapping like this :
@ComponentScan()
@EnableAutoConfiguration
public class Application {
public static void main(String[] args) {
SpringApplication app = new SpringApplication(Application.class);
app.setShowBanner(false);
app.run(args);
}
@Bean
public ServletRegistrationBean servletRegistrationBean() {
FacesServlet servlet = new javax.faces.webapp.FacesServlet();
return new ServletRegistrationBean(servlet, "/faces/*");
}
}
This is my index.xhtml :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<h:head>
</h:head>
<h:body>
<h1>Hello World</h1>
<h:form>
<p><h:outputText value="#{userView.value}"/></p>
</h:form>
</h:body>
</html>
My JSF bean :
@ViewScoped
@ManagedBean(name = "userView")
public class UserView {
private String value = "This editor is provided by PrimeFaces";
public UserView() {
super();
System.out.println("userView");
}
@PostConstruct
public void init() {
System.out.println("---------");
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
I have added the faces-config.xml :
<?xml version="1.0" encoding="UTF-8"?>
<faces-config xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd"
version="2.2">
<application>
<el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
</application>
</faces-config>
But spring don't managed my JSF bean, can you help me ?
Thanks