我想设置一个带有primefaces 10的spring 2.5.5war应用程序,以获得UI框架。
我是从关节脸开始的,但我不能解决所有的需要。然后我删除了连接wanted依赖项,并希望一步一步地设置。不幸的是,似乎还缺少一些东西,我无法真正自己弄清楚。
这是pom.xml依赖项
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-ldap</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>10.0.0</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.2.20</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.2.20</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>这是主修课
@SpringBootApplication
public class CcmtApplication {
protected CcmtApplication() { }
public static void main(String[] args) {
SpringApplication.run(CcmtApplication.class, args);
}
@Bean
ServletRegistrationBean jsfServletRegistration(ServletContext servletContext) {
//spring boot only works if this is set
servletContext.setInitParameter("com.sun.faces.forceLoadConfiguration", Boolean.TRUE.toString());
//registration
ServletRegistrationBean srb = new ServletRegistrationBean();
srb.setServlet(new FacesServlet());
srb.setUrlMappings(Arrays.asList("*.xhtml"));
srb.setLoadOnStartup(1);
return srb;
}
@Bean
public ConfigureListener mojarraConfigureListener() {
return new ConfigureListener();
}
}这是错误堆栈
2021-10-11 18:19:22.202 INFO 14726 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8443 (https)
2021-10-11 18:19:22.222 INFO 14726 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2021-10-11 18:19:22.223 INFO 14726 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.53]
2021-10-11 18:19:22.316 INFO 14726 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2021-10-11 18:19:22.316 INFO 14726 --- [ restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 2779 ms
2021-10-11 18:19:22.611 INFO 14726 --- [ restartedMain] j.e.resource.webcontainer.jsf.config : Initializing Mojarra 2.2.20 ( 20190731-0757 59754ac80c05d61848a08939ddd11a324f2345ac) for context ''
2021-10-11 18:19:22.981 INFO 14726 --- [ restartedMain] j.e.r.webcontainer.jsf.application : JSF1048: PostConstruct/PreDestroy annotations present. ManagedBeans methods marked with these annotations will have said annotations processed.
2021-10-11 18:19:24.252 ERROR 14726 --- [ restartedMain] j.e.resource.webcontainer.jsf.config : Critical error during deployment:
java.lang.NoClassDefFoundError: javax/servlet/jsp/JspFactory
at com.sun.faces.config.ConfigureListener.isJspTwoOne(ConfigureListener.java:671) ~[jsf-impl-2.2.20.jar:2.2.20]
at com.sun.faces.config.ConfigureListener.registerELResolverAndListenerWithJsp(ConfigureListener.java:691) ~[jsf-impl-2.2.20.jar:2.2.20]
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:243) ~[jsf-impl-2.2.20.jar:2.2.20]
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4766) [tomcat-embed-core-9.0.53.jar:9.0.53]
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5230) [tomcat-embed-core-9.0.53.jar:9.0.53]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [tomcat-embed-core-9.0.53.jar:9.0.53]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1396) [tomcat-embed-core-9.0.53.jar:9.0.53]我遗漏了什么?
发布于 2021-10-18 08:21:45
谢谢你的建议,但我终于解决了我的问题,没有使用连接面。
实际上,我更改pom的方式已经删除了tomcat的sprint-boot启动器。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>加法
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
</dependency>发布于 2021-10-12 13:34:44
实际上,你将不得不做很多工作,Joinfaces的人已经为你做了。
尝试这两个模板中的一个:
如果上面的内容不符合您的需要,请尝试将其设置如下:
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
/*
* Below sets up the Faces Servlet for Spring Boot
*/
@Bean
public FacesServlet facesServlet() {
return new FacesServlet();
}
@Bean
public ServletRegistrationBean<Servlet> facesServletRegistration() {
ServletRegistrationBean<Servlet> registration = new ServletRegistrationBean<>(facesServlet(), "*.xhtml");
registration.setName("FacesServlet");
return registration;
}
@Bean
public ServletListenerRegistrationBean<ConfigureListener> jsfConfigureListener() {
return new ServletListenerRegistrationBean<>(new ConfigureListener());
}}https://stackoverflow.com/questions/69529744
复制相似问题