我正在使用JoinFaces启用Spring Boot Application中的JSF工作。我已按照所需的所有步骤进行操作,但仍收到此异常消息。 java.lang.IllegalStateException:找不到WebApplicationContext:没有注册ContextLoaderListener吗?我真的错过了什么吗,我以为JoinFaces的家伙已经处理了ContextLoaderListener注册。我正在使用Tomcat apache服务器。如果没有JSF El表达式,我会在jsf页面上注意到某些内容,该页面会显示出来,但是如果我上面有EL表达式,则会得到IllegalStateException。 下面是我的代码,没有web.xml
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<joinfaces.version>master-SNAPSHOT</joinfaces.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.joinfaces</groupId>
<artifactId>joinfaces-dependencies</artifactId>
<version>${joinfaces.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.joinfaces</groupId>
<artifactId>primefaces-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.joinfaces</groupId>
<artifactId>bootsfaces-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.joinfaces</groupId>
<artifactId>omnifaces3-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.joinfaces</groupId>
<artifactId>security-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.joinfaces</groupId>
<artifactId>rewrite-spring-boot-starter</artifactId>
</dependency>
<!--
<dependency>
<groupId>org.joinfaces</groupId>
<artifactId>weld-spring-boot-starter</artifactId>
</dependency>
-->
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
</dependency>
<dependency>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-core</artifactId>
<version>3.6.0</version>
<classifier>shaded</classifier>
<exclusions>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-mapping</artifactId>
<version>3.6.0</version>
<exclusions>
<exclusion>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-extras</artifactId>
<version>3.6.0</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.13</version>
</dependency>
<dependency>
<groupId>com.googlecode.libphonenumber</groupId>
<artifactId>libphonenumber</artifactId>
<version>8.10.3</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.joinfaces</groupId>
<artifactId>joinfaces-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
src / main / resources / application.properties
jsf.PROJECT_STAGE= Development
joinfaces.faces-servlet.async-supported=true
joinfaces.faces-servlet.enabled=true
joinfaces.faces-servlet.load-on-startup=-1
joinfaces.faces-servlet.name=FacesServlet
joinfaces.faces-servlet.order=0
joinfaces.faces-servlet.url-mappings=*.xhtml
src / main / resources / META-INF / resources / content / sample.xhtml
<h:panelGrid columns="2" cellpadding="4">
<h:outputText value="First Name: " />
<p:inputText id="first-name" value="#{helloWorld.firstName}" />
<h:outputText value="Last Name: " />
<p:inputText id="last-name" value="#{helloWorld.lastName}" />
<p:commandButton id="submit" value="Submit"
update="greeting-panel"
oncomplete="PF('greetingDialog').show()" />
</h:panelGrid>
src / main / java / org / joinfaces / example / JoinFacesExampleApplication.java
@SpringBootApplication
public class JoinFacesExampleApplication {
public static void main(String[] args) {
SpringApplication.run(JoinFacesExampleApplication.class, args);
}
}
src / main / java / org / joinfaces / example / view / HelloWorld.java
@Named
public class HelloWorld {
private String firstName = "John";
private String lastName = "Doe";
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String showGreeting() {
return "Hello " + firstName + " " + lastName + "!";
}
}