{"id":347712,"date":"2023-05-20T21:00:30","date_gmt":"2023-05-20T21:00:30","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=347712"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=347712","title":{"rendered":"<span>Jakarta Faces \u0438 Spring Boot<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<p>Spring Boot \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 Tomcat Embed. Tomcat \u043d\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 Jakarta Faces \u0438 CDI. \u041d\u0435 \u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u044d\u0442\u043e, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Faces.<\/p>\n<p>\u042d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u043e \u0442\u043e\u043c, \u043a\u0430\u043a\u0430\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u043d\u0443\u0436\u043d\u0430 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 Jakarta Faces \u0432\u043c\u0435\u0441\u0442\u0435 \u0441\u043e Spring Boot. \u0422\u0430\u043a\u0436\u0435 \u044f \u043e\u043f\u0438\u0441\u0430\u043b \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0448\u0438\u0431\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u0442\u044c\u0441\u044f.<\/p>\n<h3>Tomcat<\/h3>\n<p>\u0412 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u044f \u0445\u043e\u0447\u0443 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u043e\u0435 \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441 Jakarta Faces \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0441\u044f \u043d\u0430 \u043f\u043e\u043b\u043d\u043e\u043c Tomcat.<br \/> \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u043b\u0443\u0447\u0430\u044f Mojarra README <a href=\"https:\/\/github.com\/eclipse-ee4j\/mojarra\" rel=\"noopener noreferrer nofollow\">\u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442<\/a> \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u0434\u043b\u044f CDI<\/p>\n<pre><code class=\"xml\">&lt;dependency&gt;     &lt;groupId&gt;org.jboss.weld.servlet&lt;\/groupId&gt;     &lt;artifactId&gt;weld-servlet-shaded&lt;\/artifactId&gt;     &lt;version&gt;4.0.0.Final&lt;\/version&gt; &lt;\/dependency&gt; <\/code><\/pre>\n<p>\u042d\u0442\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 Jakarta API. \u0418 \u044d\u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443. Tomcat \u0443\u0436\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0441 Jakarta API. \u041d\u043e \u043a\u043e\u0434 \u0442\u0430\u043c \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f. \u0412\u043e \u0432\u0440\u0435\u043c\u044f \u0434\u0435\u0431\u0430\u0433\u0430 IDE \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u043d\u0430 \u044d\u0442\u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u0430\u0445. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u044d\u0442\u0438 API \u0438\u0437 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439. \u041c\u043e\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a<\/p>\n<pre><code class=\"xml\">&lt;dependency&gt;     &lt;groupId&gt;org.apache.myfaces.core&lt;\/groupId&gt;     &lt;artifactId&gt;myfaces-impl&lt;\/artifactId&gt;     &lt;version&gt;4.0.0&lt;\/version&gt; &lt;\/dependency&gt; &lt;dependency&gt;     &lt;groupId&gt;jakarta.servlet&lt;\/groupId&gt;     &lt;artifactId&gt;jakarta.servlet-api&lt;\/artifactId&gt;     &lt;version&gt;6.0.0&lt;\/version&gt;     &lt;scope&gt;provided&lt;\/scope&gt; &lt;\/dependency&gt; &lt;dependency&gt;     &lt;groupId&gt;org.jboss.weld.servlet&lt;\/groupId&gt;     &lt;artifactId&gt;weld-servlet-core&lt;\/artifactId&gt;     &lt;version&gt;5.1.0.Final&lt;\/version&gt;     &lt;exclusions&gt;         &lt;exclusion&gt;             &lt;groupId&gt;jakarta.el&lt;\/groupId&gt;             &lt;artifactId&gt;jakarta.el-api&lt;\/artifactId&gt;         &lt;\/exclusion&gt;         &lt;exclusion&gt;             &lt;groupId&gt;jakarta.annotation&lt;\/groupId&gt;             &lt;artifactId&gt;jakarta.annotation-api&lt;\/artifactId&gt;         &lt;\/exclusion&gt;     &lt;\/exclusions&gt; &lt;\/dependency&gt; <\/code><\/pre>\n<p>\u0417\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c <code>weld-servlet-core<\/code> \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u043b\u0438\u0441\u0442\u0435\u043d\u0435\u0440 \u0434\u043b\u044f \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442 CDI. \u0417\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c <code>myfaces-impl<\/code> \u0441\u0430\u043c\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 FacesServlet.<\/p>\n<p>\u041c\u043d\u0435 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440, \u0447\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442.<\/p>\n<pre><code class=\"java\">import java.util.Set;  import jakarta.faces.application.ProjectStage; import jakarta.faces.component.UIInput; import jakarta.servlet.ServletContainerInitializer; import jakarta.servlet.ServletContext; import jakarta.servlet.ServletException; import jakarta.servlet.annotation.WebListener;  @WebListener public class ConfigureListener implements ServletContainerInitializer {      @Override     public void onStartup(Set&lt;Class&lt;?&gt;&gt; classes, ServletContext context) throws ServletException {         context.setInitParameter(UIInput.EMPTY_STRING_AS_NULL_PARAM_NAME, Boolean.TRUE.toString());          context.setInitParameter(ProjectStage.PROJECT_STAGE_PARAM_NAME, ProjectStage.Development.name());     } } <\/code><\/pre>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u0432\u0441\u0435. \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0433\u0443 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c xhtml \u0438 \u0431\u0438\u043d\u044b.<\/p>\n<h3>Spring Boot<\/h3>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c Spring Boot. \u042f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b <a href=\"https:\/\/start.spring.io\/\" rel=\"noopener noreferrer nofollow\">Spring Initializr<\/a> \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f jar-\u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u0441\u043f\u0440\u0438\u043d\u0433\u0430 \u0434\u043b\u044f \u0432\u0435\u0431\u0430:<\/p>\n<pre><code class=\"xml\">&lt;dependency&gt;     &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;     &lt;artifactId&gt;spring-boot-starter-web&lt;\/artifactId&gt; &lt;\/dependency&gt; <\/code><\/pre>\n<p>\u041c\u043e\u0436\u043d\u043e \u0443\u0434\u0430\u043b\u0438\u0442\u044c provided-\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u0434\u043b\u044f servlet api<\/p>\n<pre><code class=\"xml\">&lt;dependency&gt;     &lt;groupId&gt;jakarta.servlet&lt;\/groupId&gt;     &lt;artifactId&gt;jakarta.servlet-api&lt;\/artifactId&gt;     &lt;version&gt;6.0.0&lt;\/version&gt;     &lt;scope&gt;provided&lt;\/scope&gt; &lt;\/dependency&gt; <\/code><\/pre>\n<p>WEBROOT \u0434\u043b\u044f Tomcat embedded &#8212; <code>\/META-INF\/resources<\/code>. \u042f \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u044d\u0442\u0443 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e \u0432 <code>\/src\/main\/resources<\/code>. \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u043e\u0432\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \/src\/main\/resources\/META-INF\/resources\/hello.xhtml<\/p>\n<pre><code class=\"xml\">&lt;!DOCTYPE html&gt; &lt;html     xmlns=\"https:\/\/jakarta.ee\/xml\/ns\/jakartaee\"     xmlns:f=\"jakarta.faces.core\"     xmlns:h=\"jakarta.faces.html\"     xmlns:c=\"jakarta.tags.core\"&gt; &lt;h:head&gt;     &lt;title&gt;Hello World&lt;\/title&gt;     &lt;h:outputScript library=\"js\" name=\"demo.js\" \/&gt; &lt;\/h:head&gt; &lt;h:body&gt;     &lt;h1&gt;Hello World&lt;\/h1&gt;     &lt;h:form id=\"helloForm\"&gt;          &lt;h:inputText id=\"number\"             value=\"#{helloBacking.number}\"             onblur=\"demoLog(event.target.value)\"&gt;         &lt;\/h:inputText&gt;          &lt;h:commandButton id=\"submitBtn\"             value=\"Submit\"             type=\"button\"             action=\"#{helloBacking.submit}\"&gt;             &lt;f:ajax execute=\"@form\" render=\"output messages\" \/&gt;         &lt;\/h:commandButton&gt;          &lt;div&gt;             &lt;h:outputText id=\"output\" value=\"#{helloBacking.number}\" \/&gt;         &lt;\/div&gt;          &lt;h:messages id=\"messages\" showSummary=\"true\" showDetail=\"true\"\/&gt;      &lt;\/h:form&gt; &lt;\/h:body&gt; &lt;\/html&gt; <\/code><\/pre>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u0438\u0434\u0435\u0442\u044c \u0437\u0434\u0435\u0441\u044c \u0441\u043a\u0440\u0438\u043f\u0442<\/p>\n<pre><code class=\"xml\">&lt;h:outputScript library=\"js\" name=\"demo.js\" \/&gt; <\/code><\/pre>\n<p>\u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043e\u043d \u0432 \u0444\u0430\u0439\u043b\u0435 <code>\/META-INF\/resources\/resources\/js\/demo.js<\/code>. \u042f \u0432\u044b\u0437\u044b\u0432\u0430\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>demoLog<\/code> \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u043d\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 blur.<\/p>\n<p>\u0411\u0438\u043d \u0434\u043b\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b:<\/p>\n<pre><code class=\"java\">package com.example.demo.backing;  import jakarta.enterprise.context.SessionScoped; import jakarta.inject.Named;  @Named(value = \"helloWorld\") @SessionScoped public class HelloWorld implements Serializable {     private BigDecimal number;      public void submit() {         System.out.println(this.number);     }      public BigDecimal getNumber() {         return number;     }      public void setNumber(BigDecimal number) {         this.number = number;     } }  <\/code><\/pre>\n<p>\u0415\u0449\u0435 \u0434\u0432\u0430 \u0444\u0430\u0439\u043b\u0430 \u0434\u043b\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0439<\/p>\n<p>\/src\/main\/resources\/META-INF\/beans.xml<\/p>\n<pre><code class=\"xml\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt; &lt;beans     xmlns=\"https:\/\/jakarta.ee\/xml\/ns\/jakartaee\"     xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"     xsi:schemaLocation=\"https:\/\/jakarta.ee\/xml\/ns\/jakartaee         https:\/\/jakarta.ee\/xml\/ns\/jakartaee\/beans_4_0.xsd\"     version=\"4.0\" bean-discovery-mode=\"annotated\" &gt;     &lt;!-- CDI configuration here. --&gt; &lt;\/beans&gt; <\/code><\/pre>\n<p>\/src\/main\/resources\/META-INF\/resources\/WEB-INF\/faces-config.xml<\/p>\n<pre><code class=\"xml\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt; &lt;faces-config     xmlns=\"https:\/\/jakarta.ee\/xml\/ns\/jakartaee\"     xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"     xsi:schemaLocation=\"https:\/\/jakarta.ee\/xml\/ns\/jakartaee         https:\/\/jakarta.ee\/xml\/ns\/jakartaee\/web-facesconfig_4_0.xsd\"     version=\"4.0\" &gt;     &lt;!-- Faces configuration here. --&gt; &lt;\/faces-config&gt; <\/code><\/pre>\n<p>\u0418 \u044d\u0442\u043e \u0432\u0441\u0435 \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<\/p>\n<p>\u0421\u0435\u0440\u0432\u0435\u0440 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043c\u043e\u0439 xhtml. \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043d\u0435\u0442 faces servlet. \u0417\u0434\u0435\u0441\u044c \u043f\u0440\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u0441 Tomcat. \u0421\u043f\u0440\u0438\u043d\u0433\u043e\u0432\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f <a href=\"https:\/\/docs.spring.io\/spring-boot\/docs\/current\/reference\/htmlsingle\/#web.servlet.embedded-container.context-initializer\" rel=\"noopener noreferrer nofollow\">\u043d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442<\/a> \u043a\u043b\u0430\u0441\u0441\u044b <code>jakarta.servlet.ServletContainerInitializer<\/code>. \u042f \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u043f\u0440\u0438\u043d\u0433\u043e\u0432\u044b\u0439 \u0431\u0438\u043d <code>org.springframework.boot.web.servlet.ServletContextInitializer<\/code> \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0438\u0445 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e.<\/p>\n<pre><code class=\"java\">import org.springframework.boot.web.servlet.ServletContextInitializer; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration;  @Configuration public class Config {     @Bean     public ServletContextInitializer jsfInitializer() {         return new JsfInitializer();     } } <\/code><\/pre>\n<p>\u0415\u0441\u0442\u044c \u0434\u0432\u0430 <code>ServletContainerInitializer<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u0434\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c. \u0414\u043b\u044f CDI &#8212; \u044d\u0442\u043e <code>org.jboss.weld.environment.servlet.EnhancedListener<\/code>. \u0414\u043b\u044f MyFaces &#8212; <code>org.apache.myfaces.webapp.MyFacesContainerInitializer<\/code>.<\/p>\n<pre><code class=\"java\">import org.apache.myfaces.webapp.MyFacesContainerInitializer; import org.jboss.weld.environment.servlet.EnhancedListener; import org.springframework.boot.web.servlet.ServletContextInitializer;  import jakarta.faces.application.ProjectStage; import jakarta.faces.component.UIInput; import jakarta.servlet.ServletContainerInitializer; import jakarta.servlet.ServletContext; import jakarta.servlet.ServletException;  public class JsfInitializer implements ServletContextInitializer {      @Override     public void onStartup(ServletContext context) throws ServletException {         context.setInitParameter(UIInput.EMPTY_STRING_AS_NULL_PARAM_NAME, Boolean.TRUE.toString());         context.setInitParameter(ProjectStage.PROJECT_STAGE_PARAM_NAME, ProjectStage.Development.name());          EnhancedListener cdiInitializer = new EnhancedListener();         cdiInitializer.onStartup(null, context);          ServletContainerInitializer myFacesInitializer = new MyFacesContainerInitializer();         myFacesInitializer.onStartup(null, context); } } <\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043d\u043e\u0432\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430. \u0423\u0436\u0435 \u043e\u0442 FacesServlet:<\/p>\n<blockquote>\n<p>Servlet.init() for servlet [FacesServlet] threw exception<br \/> java.lang.IllegalStateException: No Factories configured for this Application. This happens if the faces-initialization does not work at all &#8212; make sure that you properly include all configuration settings necessary for a basic faces application and that all the necessary libs are included. Also check the logging output of your web application and your container for any exceptions!<br \/> If you did that and find nothing, the mistake might be due to the fact that you use some special web-containers which do not support registering context-listeners via TLD files and a context listener is not setup in your web.xml.<br \/> A typical config looks like this;<\/p>\n<\/blockquote>\n<pre><code class=\"xml\">&lt;listener&gt;     &lt;listener-class&gt;         org.apache.myfaces.webapp.StartupServletContextListener     &lt;\/listener-class&gt; &lt;\/listener&gt; <\/code><\/pre>\n<p>\u042d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e Spring \u043d\u0435 \u0441\u043a\u0430\u043d\u0438\u0440\u0443\u0435\u0442 classpath \u043d\u0430 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 servlet-\u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439 \u0438 <code>web-fragment.xml<\/code>. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0434\u043e\u043b\u0436\u0435\u043d \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u0441\u043f\u0440\u0438\u043d\u0433\u043e\u0432\u044b\u0439 \u0431\u0438\u043d \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e <code>Config.java<\/code>.<\/p>\n<pre><code class=\"java\">import org.apache.myfaces.webapp.StartupServletContextListener; import org.springframework.boot.web.servlet.ServletListenerRegistrationBean; import org.springframework.context.annotation.Bean; import jakarta.servlet.ServletContextListener;  @Bean public ServletListenerRegistrationBean&lt;ServletContextListener&gt; facesStartupServletContextListener() {     ServletListenerRegistrationBean&lt;ServletContextListener&gt; bean = new ServletListenerRegistrationBean&lt;&gt;();     bean.setListener(new StartupServletContextListener());     return bean; } <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<\/p>\n<h3>Customize faces config<\/h3>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044e \u0447\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u0432 <code>faces-config.xml<\/code> \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438. \u042f \u0445\u043e\u0447\u0443 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043b\u0443\u0448\u0430\u0442\u0435\u043b\u044f \u0434\u043b\u044f ELContext \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u0432 Java Flight Recorder.<\/p>\n<pre><code class=\"java\">import jdk.jfr.Event; import jdk.jfr.Label; import jdk.jfr.Name;  @Name(\"com.example.faces.EvaluateExpression\") @Label(\"Evaluate Expression\") public class EvaluateExpressionEvent extends Event {  @Label(\"Expression\") private String expression;  public String getExpression() { return expression; }  public void setExpression(String expression) { this.expression = expression; } } <\/code><\/pre>\n<pre><code class=\"java\">import jakarta.el.ELContext; import com.example.demo.event.EvaluateExpressionEvent;  public class EvaluationListener extends jakarta.el.EvaluationListener {  private ThreadLocal&lt;EvaluateExpressionEvent&gt; event = new ThreadLocal&lt;&gt;();  @Override     public void beforeEvaluation(ELContext context, String expression) { EvaluateExpressionEvent event = new EvaluateExpressionEvent(); event.setExpression(expression); event.begin(); this.event.set(event);     }  @Override public void afterEvaluation(ELContext context, String expression) { event.get().commit(); event.remove();     } } <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u044f \u0434\u043e\u043b\u0436\u0435\u043d \u043a\u0430\u043a-\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0435\u0433\u043e \u0432 ELContext. \u042f \u0441\u0434\u0435\u043b\u0430\u044e \u044d\u0442\u043e \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f. \u0415\u0449\u0435 \u043e\u0434\u0438\u043d listener.<\/p>\n<pre><code class=\"java\">import jakarta.el.ELContext; import jakarta.el.ELContextEvent;  public class ELContextListener implements jakarta.el.ELContextListener {  @Override public void contextCreated(ELContextEvent event) { ELContext elContext = event.getELContext(); elContext.addEvaluationListener(new EvaluationListener()); } } <\/code><\/pre>\n<p>\u042f \u0434\u043e\u043b\u0436\u0435\u043d \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0435\u0433\u043e \u0432 <code>Application<\/code>. \u0415\u0449\u0435 \u043e\u0434\u0438\u043d listener:<\/p>\n<pre><code class=\"java\">import jakarta.faces.application.Application; import jakarta.faces.event.AbortProcessingException; import jakarta.faces.event.SystemEvent; import jakarta.faces.event.SystemEventListener;  public class ApplicationCreatedListener implements SystemEventListener {  @Override public boolean isListenerForSource(Object source) { return source instanceof Application; }  @Override public void processEvent(SystemEvent event) throws AbortProcessingException { Application application = (Application) event.getSource(); application.addELContextListener(new ELContextListener()); } } <\/code><\/pre>\n<p>\u0423\u0436\u0435 \u0435\u0433\u043e \u044f \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0433\u0443 \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0432 <code>faces-config.xml<\/code>.<\/p>\n<pre><code class=\"xml\">&lt;application&gt;     &lt;system-event-listener&gt;         &lt;system-event-listener-class&gt;com.example.demo.listener.ApplicationCreatedListener&lt;\/system-event-listener-class&gt;         &lt;system-event-class&gt;jakarta.faces.event.PostConstructApplicationEvent&lt;\/system-event-class&gt;         &lt;source-class&gt;jakarta.faces.application.Application&lt;\/source-class&gt;     &lt;\/system-event-listener&gt; &lt;\/application&gt; <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u044f \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u044e \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043f\u0440\u0438 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0432 Java Mission Control. \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442 <code>face-config.xml<\/code> \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<\/p>\n<h3>\u0412\u0430\u043b\u0438\u0434\u0430\u0442\u043e\u0440 \u0438 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440<\/h3>\n<p>\u042f \u043c\u043e\u0433\u0443 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0447\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u0438\u0437 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439:<\/p>\n<pre><code class=\"java\">import jakarta.faces.component.FacesComponent; import jakarta.faces.component.behavior.FacesBehavior; import jakarta.faces.convert.FacesConverter; import jakarta.faces.event.NamedEvent; import jakarta.faces.render.FacesBehaviorRenderer; import jakarta.faces.render.FacesRenderer; import jakarta.faces.validator.FacesValidator; <\/code><\/pre>\n<p>\u042f \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u044e <code>FacesValidator<\/code> \u0438 <code>FacesConverter<\/code> \u0434\u043b\u044f \u043c\u043e\u0435\u0433\u043e input.<\/p>\n<p>\u0412\u0430\u043b\u0438\u0434\u0430\u0442\u043e\u0440:<\/p>\n<pre><code class=\"java\">import jakarta.faces.application.FacesMessage; import jakarta.faces.component.UIComponent; import jakarta.faces.context.FacesContext; import jakarta.faces.validator.FacesValidator; import jakarta.faces.validator.Validator; import jakarta.faces.validator.ValidatorException;  @FacesValidator(value = \"demo.NumberValidator\") public class NumberValidator implements Validator&lt;BigDecimal&gt;{      private Random random = new Random();      private BigDecimal getNumber() {         return new BigDecimal(random.nextDouble(420)).setScale(2, RoundingMode.HALF_UP);     }      @Override     public void validate(FacesContext context, UIComponent component, BigDecimal value)             throws ValidatorException {         if (value == null) {             return;         }         BigDecimal orig = getNumber();         if (value.compareTo(orig) &lt; 0) {             throw new ValidatorException(                     new FacesMessage(FacesMessage.SEVERITY_ERROR,                             \"Wrong number\",                             \"Number \" + value + \" less than \" + orig));         }     } } <\/code><\/pre>\n<p>\u041a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440:<\/p>\n<pre><code class=\"java\">import jakarta.faces.component.UIComponent; import jakarta.faces.context.FacesContext; import jakarta.faces.convert.Converter; import jakarta.faces.convert.ConverterException; import jakarta.faces.convert.FacesConverter;  @FacesConverter(         value = \"demo.BigDecimalConverter\",         forClass = BigDecimal.class         ) public class BigDecimalConverter implements Converter&lt;BigDecimal&gt; {      private Random random = new Random();      private BigDecimal getNumber() {         return new BigDecimal(random.nextDouble(420)).setScale(2, RoundingMode.HALF_UP);     }      @Override     public BigDecimal getAsObject(FacesContext context, UIComponent component, String value)             throws ConverterException {         if (value == null || value.trim().length() == 0) {             return getNumber();         }         try {             return new BigDecimal(value.trim()).setScale(2, RoundingMode.HALF_UP);         } catch (NumberFormatException e) {             throw new ConverterException(e.getMessage());         }     }      @Override     public String getAsString(FacesContext context, UIComponent component, BigDecimal value)             throws ConverterException {         if (value == null) {             return \"\";         }         return value.toPlainString();     } } <\/code><\/pre>\n<p>hello.xhtml<\/p>\n<pre><code class=\"xml\">&lt;h:inputText id=\"number\"             value=\"#{helloBacking.number}\"             onblur=\"demoLog(event.target.value)\"&gt;     &lt;f:converter converterId=\"demo.BigDecimalConverter\" \/&gt;     &lt;f:validator validatorId=\"demo.NumberValidator\" \/&gt;  &lt;\/h:inputText&gt; <\/code><\/pre>\n<p>\u0418 \u044d\u0442\u043e \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u041d\u043e\u0432\u044b\u0435 \u043e\u0448\u0438\u0431\u043a\u0438:<\/p>\n<blockquote>\n<p>Could not find any registered converter-class by converterId : demo.BigDecimalConverter<\/p>\n<\/blockquote>\n<blockquote>\n<p>Unknown validator id &#8216;demo.NumberValidator&#8217;.<\/p>\n<\/blockquote>\n<p>\u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e MyFaces \u0438\u0449\u0435\u0442 \u043a\u043b\u0430\u0441\u0441\u044b \u0441 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f\u043c\u0438 \u0432 <code>\/WEB-INF\/classes<\/code> \u0438\u043b\u0438 \u0432 jar-\u0444\u0430\u0439\u043b\u0430\u0445.<br \/> \u042d\u0442\u043e \u043d\u0435 WAR \u0438 \u0437\u0434\u0435\u0441\u044c \u043d\u0435\u0442 <code>\/WEB-INF\/classes<\/code>. \u042f \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u044e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0438\u0437 IDE, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u043e\u0438 \u043a\u043b\u0430\u0441\u0441\u044b \u043d\u0435 \u0432 jar. \u0415\u0441\u043b\u0438 \u044f \u0441\u043e\u0431\u0435\u0440\u0443 \u043f\u0440\u043e\u0435\u043a\u0442 \u0438 \u0437\u0430\u043f\u0443\u0449\u0443  jar, \u0442\u043e\u0433\u0434\u0430 \u0437\u0430\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u041d\u043e \u043c\u043d\u0435 \u043d\u0430\u0434\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0432 IDE \u0442\u043e\u0436\u0435. \u0417\u0434\u0435\u0441\u044c \u0442\u0440\u0438 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b.<\/p>\n<p>\u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u044f \u043c\u043e\u0433\u0443 \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c <code>org.apache.myfaces.spi.AnnotationProvider<\/code> \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044f <code>ClassPathScanningCandidateComponentProvider<\/code> \u0438\u0437 \u0441\u043f\u0440\u0438\u043d\u0433\u0430.<\/p>\n<pre><code class=\"java\">import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider; import org.springframework.core.type.filter.AnnotationTypeFilter;  import jakarta.faces.component.FacesComponent; import jakarta.faces.component.behavior.FacesBehavior; import jakarta.faces.context.ExternalContext; import jakarta.faces.convert.FacesConverter; import jakarta.faces.event.NamedEvent; import jakarta.faces.render.FacesBehaviorRenderer; import jakarta.faces.render.FacesRenderer; import jakarta.faces.validator.FacesValidator;  public class AnnotationProvider extends org.apache.myfaces.spi.AnnotationProvider {          private static Set&lt;Class&lt;? extends Annotation&gt;&gt; annotationsToScan;      static {         annotationsToScan = new HashSet&lt;&gt;(7, 1f);         annotationsToScan.add(FacesComponent.class);         annotationsToScan.add(FacesBehavior.class);         annotationsToScan.add(FacesConverter.class);         annotationsToScan.add(FacesValidator.class);         annotationsToScan.add(FacesRenderer.class);         annotationsToScan.add(NamedEvent.class);         annotationsToScan.add(FacesBehaviorRenderer.class);     }      @Override     public Map&lt;Class&lt;? extends Annotation&gt;, Set&lt;Class&lt;?&gt;&gt;&gt; getAnnotatedClasses(ExternalContext ctx) {         Map&lt;Class&lt;? extends Annotation&gt;, Set&lt;Class&lt;?&gt;&gt;&gt; result = new HashMap&lt;&gt;();                  ClassLoader cl = getClass().getClassLoader();         Package[] packages = cl.getDefinedPackages();         for (Package pack : packages) {             pack.getName();         }         ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false);         for (Class&lt;? extends Annotation&gt; a : annotationsToScan) {             provider.addIncludeFilter(new AnnotationTypeFilter(a));         }         Set&lt;BeanDefinition&gt; components = provider.findCandidateComponents(\"com.example.demo\");         for (BeanDefinition c : components) {             Class&lt;?&gt; clazz;             try {                 clazz = cl.loadClass(c.getBeanClassName());             } catch (ClassNotFoundException e) {                 e.printStackTrace();                 continue;             }             for (Class&lt;? extends Annotation&gt; a : annotationsToScan) {                 Annotation an = clazz.getDeclaredAnnotation(a);                 if (an != null) {                     Set&lt;Class&lt;?&gt;&gt; annotationSet = result.get(a);                     if (annotationSet == null) {                         annotationSet = new HashSet&lt;&gt;();                         result.put(a, annotationSet);                     }                     annotationSet.add(clazz);                 }             }         }         return result;     }      @Override     public Set&lt;URL&gt; getBaseUrls(ExternalContext ctx) throws IOException {         return null;     } } <\/code><\/pre>\n<p>\u0417\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0439 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440 \u0432 \u0444\u0430\u0439\u043b\u0435 src\/main\/resources\/META-INF\/services\/org.apache.myfaces.spi.AnnotationProvider<\/p>\n<pre><code>com.example.demo.config.AnnotationProvider <\/code><\/pre>\n<p>\u0412\u0442\u043e\u0440\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 &#8212; \u044d\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442.<\/p>\n<pre><code class=\"java\">import org.apache.myfaces.config.webparameters.MyfacesConfig;  context.setInitParameter(MyfacesConfig.SCAN_PACKAGES, \"com.example.demo\"); <\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0430\u043a\u0442\u0438\u0432\u0438\u0440\u0443\u0435\u0442 \u0434\u0440\u0443\u0433\u0443\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u041f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u043a\u0430\u043a \u0432 \u043c\u043e\u0435\u043c \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0435, \u043d\u043e \u0431\u0435\u0437 \u0441\u043f\u0440\u0438\u043d\u0433\u0430. \u041f\u043e\u0447\u0435\u043c\u0443 \u0437\u0434\u0435\u0441\u044c \u0434\u0432\u0430 \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f? \u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u044b \u0438\u0437 \u0432\u0441\u0435\u0445 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439 &#8212; \u044d\u0442\u043e \u043d\u0430\u043a\u043b\u0430\u0434\u043d\u043e. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e MyFaces \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0438\u0442\u0430\u0435\u0442 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438 \u0438\u0437 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 *.class \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043b\u0430\u0441\u0441\u044b \u0441 \u043d\u0443\u0436\u043d\u044b\u043c\u0438 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f\u043c\u0438. \u0414\u043b\u044f \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u043d\u0443\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u044f\u0432\u043d\u043e \u043f\u0430\u043a\u0435\u0442\u044b \u0434\u043b\u044f \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p>\u0422\u0440\u0435\u0442\u0438\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 &#8212; \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440:<\/p>\n<pre><code class=\"java\">context.setInitParameter(     MyfacesConfig.USE_CDI_FOR_ANNOTATION_SCANNING, Boolean.TRUE.toString()); <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c MyFaces \u043e\u0431\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043a CDI \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0431\u0438\u043d\u043e\u0432 \u0441 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f\u043c\u0438. \u041d\u043e \u043c\u043e\u0438 \u043a\u043b\u0430\u0441\u0441\u044b &#8212; \u043d\u0435 CDI-\u0431\u0438\u043d\u044b. \u042f \u0434\u043e\u043b\u0436\u0435\u043d \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e <code>@Dependent<\/code> \u0438 \u0442\u043e\u0433\u0434\u0430 \u044d\u0442\u043e\u0442 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0437\u0430\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<\/p>\n<h3>\u0418\u043d\u044a\u0435\u043a\u0446\u0438\u044f \u0431\u0438\u043d\u043e\u0432 \u0432 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440 \u0438 \u0432\u0430\u043b\u0438\u0434\u0430\u0442\u043e\u0440<\/h3>\n<p>\u0414\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u044f \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0443 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u0447\u0438\u0441\u0435\u043b \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0438 \u0441\u0434\u0435\u043b\u0430\u044e \u0435\u0433\u043e \u0438\u043d\u044a\u0435\u043a\u0446\u0438\u044e \u0432 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440 \u0438 \u0432\u0430\u043b\u0438\u0434\u0430\u0442\u043e\u0440.<\/p>\n<pre><code class=\"java\">@Named @ApplicationScoped public class DemoRepository {  private Random random = new Random();  public BigDecimal getNumber() { return new BigDecimal(random.nextDouble(420)).setScale(2, RoundingMode.HALF_UP); } } <\/code><\/pre>\n<pre><code class=\"java\">public class BigDecimalConverter implements Converter&lt;BigDecimal&gt; {     @Inject private DemoRepository demoRepository; <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0443 \u043c\u0435\u043d\u044f NPE. DemoRepository = null. \u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440 \u043d\u0435 CDI-\u0431\u0438\u043d. \u0415\u0441\u043b\u0438 \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 CDI \u0434\u043b\u044f \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u044d\u0442\u043e\u0433\u043e \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e. \u0421\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043c\u0430\u043f\u0443 \u0441 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438. \u0412\u043e \u0432\u0440\u0435\u043c\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 MyFaces \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0431\u0435\u0437 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432. \u0415\u0449\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u044b \u043f\u0440\u043e\u043f\u0435\u0440\u0442\u0438 \u0438\u0437 faces-config, \u043a\u043e\u0433\u0434\u0430 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043b\u0441\u044f \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0435. \u042d\u0442\u043e \u043d\u0435 \u043c\u043e\u0439 \u0441\u043b\u0443\u0447\u0430\u0439. \u0427\u0442\u043e\u0431\u044b \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440\u0430 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u043b\u0441\u044f \u0438\u0437 CDI, \u044f \u0434\u043e\u043b\u0436\u0435\u043d \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c <code>managed = true<\/code> \u0432 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440\u0430.<\/p>\n<p>\u0421\u0440\u0430\u0437\u0443 \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u044f \u043f\u043e\u043b\u0443\u0447\u0430\u044e \u043d\u043e\u0432\u0443\u044e \u043e\u0448\u0438\u0431\u043a\u0443:<\/p>\n<blockquote>\n<p>Cannot invoke &#171;jakarta.faces.convert.Converter.getAsString(jakarta.faces.context.FacesContext, jakarta.faces.component.UIComponent, Object)&#187; because the return value of &#171;org.apache.myfaces.cdi.wrapper.FacesConverterCDIWrapper.getWrapped()&#187; is null<\/p>\n<\/blockquote>\n<p>CDI \u043d\u0435 \u0437\u043d\u0430\u0435\u0442 \u0442\u0430\u043a\u0438\u0445 \u0431\u0438\u043d\u043e\u0432. \u041a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043f\u043e\u043c\u0435\u0447\u0435\u043d \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0435\u0439 <code>@Dependent<\/code>. \u041f\u0440\u043e\u0431\u0443\u044e \u0441\u043d\u043e\u0432\u0430 &#8212; \u0442\u0430\u0436\u0435 \u043e\u0448\u0438\u0431\u043a\u0430. \u0411\u0438\u043d \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442, \u043d\u043e CDI \u043d\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u0435\u0433\u043e. \u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440 \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u043c\u0435\u0442\u044c ID<\/p>\n<pre><code class=\"xml\">&lt;f:converter converterId=\"demo.BigDecimalConverter\" \/&gt; <\/code><\/pre>\n<p>\u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442 Myfaces \u0438\u0449\u0435\u0442 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440 \u043f\u043e \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438<\/p>\n<pre><code class=\"java\">@FacesConverter(         value = \"demo.BigDecimalConverter\",         forClass = Object.class,         managed = true         ) <\/code><\/pre>\n<p>\u041d\u043e \u0443 \u043c\u043e\u0435\u0433\u043e \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440\u0430 \u0443\u043a\u0430\u0437\u0430\u043d\u043e <code>forClass = BigDecimal.class<\/code>. \u0412 \u044d\u0442\u043e\u043c \u043e\u0448\u0438\u0431\u043a\u0430. \u042f \u0434\u043e\u043b\u0436\u0435\u043d \u0443\u0434\u0430\u043b\u0438\u0442\u044c <code>forClass<\/code> \u0443 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440\u0430. \u0418\u043b\u0438 \u044f \u043c\u043e\u0433\u0443 \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0442\u0435\u0433 <code>f:converter<\/code> \u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0443\u0434\u0430\u043b\u0438\u0442\u044c <code>value<\/code> \u0443 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440\u0430. \u0427\u0442\u043e-\u0442\u043e \u043e\u0434\u043d\u043e. \u042f \u0443\u0434\u0430\u043b\u0438\u043b <code>forClass<\/code>. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043c\u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440 \u0434\u043b\u044f \u0438\u043d\u043f\u0443\u0442\u043e\u0432 \u0441 \u0442\u0435\u0433\u043e\u043c \u0438 \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440 \u0434\u043b\u044f \u0434\u0440\u0443\u0433\u0438\u0445 BigDecimal \u043f\u043e\u043b\u0435\u0439.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u044f \u0438\u043d\u044a\u0435\u043a\u0446\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<\/p>\n<h3>\u0418\u043d\u044a\u0435\u043a\u0446\u0438\u044f \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 Faces<\/h3>\n<p>Jakarta Faces \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0442\u0430\u043a\u0438\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u043a\u0430\u043a <code>FacesContext<\/code>, <code>ExternalContext<\/code>, <code>ResourceHandler<\/code>, \u0438 \u0434\u0440\u0443\u0433\u0438\u0435. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0437\u0430\u0441\u0435\u0442\u0438\u0442\u044c \u0432 \u0431\u0438\u043d \u0438\u043d\u0438\u0442-\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044f \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u043b \u0432 \u043c\u043e\u0435\u043c \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0435.<\/p>\n<pre><code class=\"java\">import jakarta.faces.annotation.InitParameterMap;  @Inject @InitParameterMap private Map&lt;String, String&gt; initParam;  System.out.println(\"Empty as null = \"     + this.initParam.get(UIInput.EMPTY_STRING_AS_NULL_PARAM_NAME)); <\/code><\/pre>\n<p>\u042f \u043f\u043e\u043b\u0443\u0447\u0430\u044e \u043e\u0448\u0438\u0431\u043a\u0443:<\/p>\n<blockquote>\n<p>ConfigServletWebServerApplicationContext : Exception encountered during context initialization &#8212; cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name &#8216;helloBacking&#8217;: Unsatisfied dependency expressed through field &#8216;initParam&#8217;: No qualifying bean of type &#8216;java.util.Map&lt;java.lang.String, java.lang.String&gt;&#8217; available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: <a class=\"mention\" href=\"\/users\/jakarta\">@jakarta<\/a>a.inject.Inject(), <a class=\"mention\" href=\"\/users\/jakarta\">@jakarta<\/a>.faces.annotation.InitParameterMap()}<\/p>\n<\/blockquote>\n<p>\u042d\u0442\u043e \u0443\u0436\u0435 \u043e\u0442 \u0441\u043f\u0440\u0438\u043d\u0433\u0430. Spring \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0431\u0438\u043d\u044b \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 Jakarta \u0434\u043b\u044f \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u0430\u043d\u0434\u0438\u0434\u0430\u0442\u043e\u0432 \u0432 \u0431\u0438\u043d\u044b.<br \/> <code>ClassPathScanningCandidateComponentProvider<\/code> \u0438\u043c\u0435\u0435\u0442 <code>includedFilters<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432 Spring Boot 3 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043f\u043e \u0434\u0435\u0444\u043e\u043b\u0442\u0443 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438:<\/p>\n<pre><code class=\"java\">    import org.springframework.stereotype.Component;     import jakarta.annotation.ManagedBean;     import jakarta.inject.Named; <\/code><\/pre>\n<p>\u042f \u043f\u043e\u043f\u0440\u0430\u0432\u043b\u044e \u044d\u0442\u043e\u0442 \u043a\u043e\u043d\u0444\u043b\u0438\u043a\u0442, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 <code>@ComponentScan<\/code> \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u041e\u0441\u0442\u0430\u0432\u043b\u044e \u0434\u043b\u044f \u0441\u043f\u0440\u0438\u043d\u0433\u0430 \u0442\u043e\u043b\u044c\u043a\u043e <code>@Component<\/code>.<\/p>\n<pre><code class=\"java\">import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.FilterType; import org.springframework.stereotype.Component;  @ComponentScan(         useDefaultFilters = false,         includeFilters = {             @ComponentScan.Filter(                 type = FilterType.ANNOTATION,                 value = Component.class)         }     ) @SpringBootApplication <\/code><\/pre>\n<h3>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 Spring-\u0431\u0438\u043d\u043e\u0432<\/h3>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 Spring Boot, \u0442\u043e \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u0441\u043f\u0440\u0438\u043d\u0433\u043e\u0432\u044b\u0435 \u0431\u0438\u043d\u044b. \u0418 \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u0432\u044b \u0437\u0430\u0445\u043e\u0442\u0438\u0442\u0435 \u0438\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f Faces. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043e\u0431\u0440\u0430\u0442\u0438\u043c <code>DemoRepository<\/code> \u0432 \u0441\u043f\u0440\u0438\u043d\u0433\u043e\u0432\u044b\u0439 \u0431\u0438\u043d.<\/p>\n<pre><code class=\"java\">import org.springframework.stereotype.Repository;  @Repository public class DemoRepository { <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0443 \u043c\u0435\u043d\u044f \u043e\u0448\u0438\u0431\u043a\u0430. CDI \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u043d\u0443\u0436\u043d\u043e\u0433\u043e \u0431\u0438\u043d\u0430 \u0434\u043b\u044f \u0438\u043d\u044a\u0435\u043a\u0446\u0438\u0438 \u0432 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440.<\/p>\n<blockquote>\n<p>Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type DemoRepository with qualifiers <a class=\"mention\" href=\"\/users\/Default\">@Default<\/a><br \/> at injection point [BackedAnnotatedField] <a class=\"mention\" href=\"\/users\/Inject\">@Inject<\/a> private com.example.demo.converter.BigDecimalConverter.demoRepository<br \/> at com.example.demo.converter.BigDecimalConverter.demoRepository(BigDecimalConverter.java:0)<\/p>\n<\/blockquote>\n<p>\u042f \u043c\u043e\u0433\u0443 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c CDI-\u043f\u0440\u043e\u0434\u044c\u044e\u0441\u0435\u0440 \u0434\u043b\u044f \u0441\u043f\u0440\u0438\u043d\u0433\u043e\u0432\u043e\u0433\u043e <code>ApplicationContext<\/code>. \u0417\u0430\u0438\u043d\u0436\u0435\u043a\u0442\u0438\u0442\u044c \u0435\u0433\u043e. \u0418 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0442\u044c \u0443 \u043d\u0435\u0433\u043e \u043d\u0443\u0436\u043d\u044b\u0439 \u0431\u0438\u043d \u0432 <code>@PostConstruct<\/code> \u043c\u0435\u0442\u043e\u0434\u0435.<\/p>\n<pre><code class=\"java\">import org.springframework.context.ApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils;  import jakarta.enterprise.context.Dependent; import jakarta.enterprise.inject.Produces; import jakarta.servlet.ServletContext;  @Dependent public class SpringBeanProducer {  @Produces public ApplicationContext springContext(ServletContext sctx) { ApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(sctx); return ctx; } } <\/code><\/pre>\n<p>\u0412 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440\u0435:<\/p>\n<pre><code class=\"java\">import jakarta.annotation.PostConstruct;  private DemoRepository demoRepository;  @Inject private ApplicationContext springContext;  @PostConstruct private void init() {     this.demoRepository = springContext.getBean(DemoRepository.class); }  <\/code><\/pre>\n<p>\u041c\u043e\u0433\u0443 \u043b\u0438 \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u043e\u0434\u044c\u044e\u0441\u0435\u0440 \u0441\u0440\u0430\u0437\u0443 \u0434\u043b\u044f \u0431\u0438\u043d\u043e\u0432? \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u044e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435.<\/p>\n<p>\u0412 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044e \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e:<\/p>\n<pre><code class=\"java\">import com.example.demo.config.SpringBeanProducer.SpringBean;  @Inject @SpringBean @Qualifier(\"demoRepository\") private DemoRepository demoRepository; <\/code><\/pre>\n<p>\u0418 \u043d\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0434\u044c\u044e\u0441\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0449\u0435\u0442 \u0431\u0438\u043d \u043f\u043e \u043a\u043b\u0430\u0441\u0441\u0443 \u0438 \u0438\u043c\u0435\u043d\u0438:<\/p>\n<pre><code class=\"java\">import jakarta.enterprise.inject.spi.InjectionPoint; import jakarta.inject.Qualifier;  @Qualifier @Retention(RetentionPolicy.RUNTIME) public @interface SpringBean { }  @Produces @SpringBean public Object create(InjectionPoint ip, ServletContext sctx) {     Class beanClass = (Class) ip.getType();     Set&lt;Annotation&gt; qualifiers = ip.getAnnotated().getAnnotations();     String beanName = null;     for (Annotation a : qualifiers) {         if (a instanceof org.springframework.beans.factory.annotation.Qualifier q) {             beanName = q.value();         }     }      ApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(sctx);     if (beanName != null &amp;&amp; !beanName.isBlank()) {         return ctx.getBean(beanName, beanClass);     }              return ctx.getBean(beanClass); } <\/code><\/pre>\n<p>\u041d\u043e \u044d\u0442\u043e \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e CDI \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c <code>DemoRepository.class<\/code> \u0438 <code>Object.class<\/code>. \u041e\u043d \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0434\u044c\u044e\u0441\u0435\u0440, \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u043e\u043d \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043d\u0443\u0436\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441. \u0410\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 <code>@SpringBean<\/code> \u043c\u0430\u043b\u043e. \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u044f \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u043f\u0440\u043e\u0434\u044c\u044e\u0441\u0435\u0440 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0431\u0438\u043d\u0430. \u0415\u0441\u043b\u0438 \u0438\u0445 \u043c\u043d\u043e\u0433\u043e, \u0442\u043e \u044d\u0442\u043e \u043d\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435. \u0418\u043b\u0438 \u044f \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u043d\u0436\u0435\u043a\u0442\u0438\u0442\u044c \u0431\u0438\u043d \u0432 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440 \u043a\u0430\u043a Object. \u0423\u0434\u043e\u0431\u043d\u0435\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0435\u0442\u0442\u0435\u0440 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u043d\u044a\u0435\u043a\u0446\u0438\u0438, \u0447\u0435\u043c \u043f\u0440\u043e\u0434\u044c\u044e\u0441\u0435\u0440 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0431\u0438\u043d\u0430.<\/p>\n<pre><code class=\"java\">import org.springframework.beans.factory.annotation.Qualifier;  private DemoRepository demoRepository;  @Inject public void setDemoRepository(     @SpringBean @Qualifier(\"demoRepository\") Object repository) {     this.demoRepository = (DemoRepository) repository; } <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u044f \u043c\u043e\u0433\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Spring \u0432 CDI.<\/p>\n<p>\u041c\u043e\u0436\u043d\u043e \u043b\u0438 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0438\u0437 CDI \u0432 Spring? \u042f \u043c\u043e\u0433\u0443 \u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0432 <code>@PostConstruct<\/code> \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c:<\/p>\n<pre><code class=\"java\">import jakarta.enterprise.inject.spi.CDI; import jakarta.enterprise.util.TypeLiteral; import jakarta.faces.annotation.InitParameterMap;  private Map&lt;String, String&gt; initParam;  @PostConstruct private void init() {     this.initParam = CDI.current().select(             new TypeLiteral&lt;Map&lt;String, String&gt;&gt;() {},             new InitParameterMap.Literal()         ).get(); } <\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0448\u0430\u0433 &#8212; \u044d\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Spring-\u0431\u0438\u043d\u044b \u043f\u0440\u044f\u043c\u043e \u0432 xhtml. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u0435\u043d ELResolver. Spring \u0443\u0436\u0435 \u0438\u043c\u0435\u0435\u0442 \u0442\u0430\u043a\u043e\u0439. \u041e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 <code>faces-config.xml<\/code>.<\/p>\n<pre><code class=\"xml\">&lt;application&gt;     &lt;el-resolver&gt;         org.springframework.web.jsf.el.SpringBeanFacesELResolver     &lt;\/el-resolver&gt; &lt;\/application&gt; <\/code><\/pre>\n<h3>\u0421\u0431\u043e\u0440\u043a\u0430 JAR<\/h3>\n<p>\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0440\u0430\u0431\u043e\u0447\u0435\u0439. \u041c\u043e\u0436\u043d\u043e \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c.<\/p>\n<blockquote>\n<p>mvn package<\/p>\n<\/blockquote>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0441\u043e\u0431\u0440\u0430\u043d\u043d\u044b\u0439 jar \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e Spring Boot \u0434\u0435\u043b\u0430\u0435\u0442 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u044b\u0439 fat jar \u0441 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u043c\u0438 \u0432\u043d\u0443\u0442\u0440\u0438 \u0438 \u0434\u0435\u043b\u0430\u0435\u0442 \u0441\u0432\u043e\u0439 ClassLoader \u0434\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0432\u0441\u0435\u0433\u043e \u044d\u0442\u043e\u0433\u043e.<\/p>\n<p>\u042f \u043c\u043e\u0433\u0443 \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u044d\u0442\u043e<\/p>\n<pre><code class=\"xml\">&lt;plugin&gt;     &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;     &lt;artifactId&gt;spring-boot-maven-plugin&lt;\/artifactId&gt; &lt;\/plugin&gt; <\/code><\/pre>\n<p>\u043d\u0430 \u044d\u0442\u043e<\/p>\n<pre><code class=\"xml\">&lt;plugin&gt;     &lt;groupId&gt;org.apache.maven.plugins&lt;\/groupId&gt;     &lt;artifactId&gt;maven-dependency-plugin&lt;\/artifactId&gt;     &lt;executions&gt;         &lt;execution&gt;             &lt;id&gt;copy-dependencies&lt;\/id&gt;             &lt;phase&gt;prepare-package&lt;\/phase&gt;             &lt;goals&gt;                 &lt;goal&gt;copy-dependencies&lt;\/goal&gt;             &lt;\/goals&gt;             &lt;configuration&gt;                 &lt;outputDirectory&gt;                     ${project.build.directory}\/libs                 &lt;\/outputDirectory&gt;             &lt;\/configuration&gt;         &lt;\/execution&gt;     &lt;\/executions&gt; &lt;\/plugin&gt;  &lt;plugin&gt;     &lt;groupId&gt;org.apache.maven.plugins&lt;\/groupId&gt;     &lt;artifactId&gt;maven-jar-plugin&lt;\/artifactId&gt;     &lt;configuration&gt;         &lt;archive&gt;             &lt;manifest&gt;                 &lt;addClasspath&gt;true&lt;\/addClasspath&gt;                 &lt;classpathPrefix&gt;libs\/&lt;\/classpathPrefix&gt;                 &lt;mainClass&gt;                     com.example.demo.DemoApplication                 &lt;\/mainClass&gt;             &lt;\/manifest&gt;         &lt;\/archive&gt;     &lt;\/configuration&gt; &lt;\/plugin&gt; <\/code><\/pre>\n<p>\u041f\u043e-\u043c\u043e\u0435\u043c\u0443 \u044d\u0442\u043e \u043b\u0443\u0447\u0448\u0438\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442. \u0421\u043f\u0440\u0438\u043d\u0433\u043e\u0432\u0430\u044f \u0441\u0431\u043e\u0440\u043a\u0430 \u043c\u0443\u0434\u0440\u0435\u043d\u0430\u044f \u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0435\u0449\u0451 \u043e\u0434\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u043e\u0439 \u043e\u0442\u043a\u0430\u0437\u0430. \u041d\u0435 \u0432\u0441\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043c\u043e\u0433\u0443\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0442\u0430\u043a\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439 \u0430\u0440\u0445\u0438\u0432\u0430.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0443\u043f\u0430\u043a\u043e\u0432\u043a\u0443 \u043e\u0442 Spring Boot, \u0442\u043e \u0432\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0440\u0435\u0448\u0438\u0442\u044c \u0434\u0432\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b.<\/p>\n<h4>1. CDI<\/h4>\n<p>CDI \u0438\u0449\u0435\u0442 \u0431\u0438\u043d\u044b, \u043e\u0431\u0445\u043e\u0434\u044f \u0444\u0430\u0439\u043b\u043e\u0432\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0430\u0440\u0445\u0438\u0432\u0430. \u0418 \u0438\u043c\u044f \u043a\u043b\u0430\u0441\u0441\u0430 \u0432 \u0438\u0442\u043e\u0433\u0435 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0438\u0437 \u043f\u0443\u0442\u0438. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0438\u043c\u044f \u043a\u043b\u0430\u0441\u0441\u0430 \u0431\u0443\u0434\u0435\u0442<br \/> <code>BOOT-INF.classes.com.example.demo.converter.BigDecimalConverter<\/code><\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u044d\u0442\u043e \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u043d\u0430\u0434\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u044e \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044e \u043f\u043e\u0438\u0441\u043a\u0430. \u042f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e <code>jandex<\/code>. \u0411\u0443\u0434\u0443 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044e \u0438\u0437 \u044d\u0442\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438.<\/p>\n<pre><code class=\"xml\">&lt;dependency&gt;     &lt;groupId&gt;org.jboss&lt;\/groupId&gt;     &lt;artifactId&gt;jandex&lt;\/artifactId&gt;     &lt;version&gt;3.1.1&lt;\/version&gt; &lt;\/dependency&gt; <\/code><\/pre>\n<p>\u0418\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u044e \u0441\u0432\u043e\u0439 <code>org.jboss.weld.environment.deployment.discovery.BeanArchiveHandler<\/code>. \u0418 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u044e \u0435\u0433\u043e \u0432 META-INF\/services.<\/p>\n<pre><code class=\"java\">import org.jboss.weld.environment.deployment.discovery.BeanArchiveBuilder; import org.jboss.weld.environment.deployment.discovery.jandex.JandexFileSystemBeanArchiveHandler; import jakarta.annotation.Priority;  @Priority(100) public class SpringBootFileSystemBeanArchiveHandler extends JandexFileSystemBeanArchiveHandler {      private static final String BOOT_INF_CLASSES = \"BOOT-INF\/classes\/\";      @Override     public BeanArchiveBuilder handle(String path) {         \/\/ use only for spring boot build         if (!path.toLowerCase().endsWith(\".jar\")) {             \/\/ try other handlers             return null;         }         return super.handle(path);     }      @Override     protected void add(Entry entry, BeanArchiveBuilder builder) throws MalformedURLException {         if (!entry.getName().startsWith(BOOT_INF_CLASSES)                 || !entry.getName().endsWith(CLASS_FILE_EXTENSION)) {             \/\/ skip spring classes for loader and other resources              return;         }         entry = new SpringBootEntry(entry);         super.add(entry, builder);     }          protected class SpringBootEntry implements Entry {          private Entry delegate;                  public SpringBootEntry(Entry entry) {             this.delegate = entry;         }          @Override         public String getName() {             String name = delegate.getName();             \/\/ cut off prefix from class name             name = name.substring(BOOT_INF_CLASSES.length());             return name;         }          @Override         public URL getUrl() throws MalformedURLException {             return delegate.getUrl();         }              } } <\/code><\/pre>\n<p>\u0410\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f <code>@Priority(100)<\/code> \u0432\u0430\u0436\u043d\u0430. \u041a\u043b\u0430\u0441\u0441 \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d \u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c. \u0415\u0441\u043b\u0438 \u0434\u0440\u0443\u0433\u043e\u0439 BeanArchiveBuilder \u043d\u0430\u0439\u0434\u0435\u0442 \u0447\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u043f\u0435\u0440\u0432\u044b\u043c, \u0442\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f.<\/p>\n<h4>2. Tomcat static resources<\/h4>\n<p>Tomcat \u0447\u0438\u0442\u0430\u0435\u0442 \u0441\u0442\u0430\u0442\u0438\u043a\u0443 \u0438\u0437 jar. Tomcat \u043e\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442 \u0432\u0441\u0435 url \u0438\u0437 URLClassLoader \u043d\u0430 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 <code>\/META-INF\/resources<\/code>. \u0418 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u044d\u0442\u0438 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u043a\u0430\u043a WEBROOT \u0434\u043b\u044f \u0441\u0442\u0430\u0442\u0438\u043a\u0438. Spring Boot \u0443\u043f\u0430\u043a\u043e\u0432\u044b\u0432\u0430\u0435\u0442 <code>\/src\/main\/resources<\/code> \u0432 \u043a\u043e\u0440\u0435\u043d\u044c \u0430\u0440\u0445\u0438\u0432\u0430. \u041d\u043e \u043d\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043a\u043e\u0440\u0435\u043d\u044c \u0432 ClassLoader, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0437\u0434\u0430\u0435\u0442. \u0422\u0430\u043c \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e <code>\/BOOT-INF\/classes<\/code> \u0438 \u0432\u0441\u0435 \u0430\u0440\u0445\u0438\u0432\u044b \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439. \u041f\u043e\u0447\u0435\u043c\u0443 \u0441\u043f\u0440\u0438\u043d\u0433 \u043d\u0435 \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442 \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u0432 <code>\/BOOT-INF\/classes<\/code> \u0442\u043e\u0433\u0434\u0430? \u0415\u0441\u0442\u044c <a href=\"https:\/\/github.com\/spring-projects\/spring-boot\/issues\/8299\" rel=\"noopener noreferrer nofollow\">issue<\/a> \u043d\u0430 \u044d\u0442\u043e. \u0418 \u043a\u043e\u0433\u0434\u0430 \u043b\u044e\u0434\u0438 \u0438\u0437 \u0441\u043f\u0440\u0438\u043d\u0433\u0430 \u0433\u043e\u0432\u043e\u0440\u044f\u0442 \u043e jar, \u043e\u043d\u0438 \u0437\u0430\u0431\u044b\u0432\u0430\u044e, \u0447\u0442\u043e \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u043c. \u041f\u043e \u0438\u0445 \u043c\u043d\u0435\u043d\u0438\u044e jar &#8212; \u044d\u0442\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u0434\u043b\u044f \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u0432\u0435\u0431-\u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<p>\u041a\u0430\u043a \u0432\u044b \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442\u0435 \u0440\u0435\u0448\u0438\u0442\u044c \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u043c\u043e\u0436\u043d\u043e, \u0432\u044b\u0434\u0435\u043b\u0438\u0432 \u0432\u0441\u0435 \u0434\u043b\u044f Faces \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c \u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0432 \u043a\u0430\u043a \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c. \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0441 CDI \u044d\u0442\u043e \u0442\u043e\u0436\u0435 \u043c\u043e\u0436\u0435\u0442 \u0440\u0435\u0448\u0438\u0442\u044c.<\/p>\n<p>\u042f \u0436\u0435 \u043d\u0430\u043f\u0438\u0448\u0443 \u0441\u0432\u043e\u044e <code>ConfigurableTomcatWebServerFactory<\/code> \u0441\u043e \u0441\u043b\u0443\u0448\u0430\u0442\u0435\u043b\u0435\u043c \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0442\u043e\u043c\u043a\u0430\u0442\u0430. \u0421\u043b\u0443\u0448\u0430\u0442\u0435\u043b\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u0442 \u0435\u0449\u0451 \u043e\u0434\u0438\u043d \u0440\u0435\u0441\u0443\u0440\u0441 \u0434\u043b\u044f \u0441\u0442\u0430\u0442\u0438\u043a\u0438.<\/p>\n<pre><code class=\"java\">@Bean public TomcatServletWebServerFactory tomcatFactory() {     TomcatFactory factory = new TomcatFactory();     return factory; } <\/code><\/pre>\n<pre><code class=\"java\">import org.apache.catalina.Context; import org.apache.catalina.Lifecycle; import org.apache.catalina.LifecycleEvent; import org.apache.catalina.LifecycleListener; import org.apache.catalina.WebResourceRoot.ResourceSetType; import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;  public class TomcatFactory extends TomcatServletWebServerFactory {      @Override     protected void postProcessContext(Context context) {         context.addLifecycleListener(new WebResourcesConfigurer(context));     }          public class WebResourcesConfigurer implements LifecycleListener {                  private static final String META_INF_RESOURCES = \"META-INF\/resources\";         private Context context;          public WebResourcesConfigurer(Context context) {             this.context = context;         }          @Override         public void lifecycleEvent(LifecycleEvent event) {             if (event.getType().equals(Lifecycle.CONFIGURE_START_EVENT)) {                 ClassLoader classLoader = getClass().getClassLoader();                 if (!(classLoader instanceof URLClassLoader)) {                     return;                 }                 URL jarRoot = classLoader.getResource(META_INF_RESOURCES);                 if (jarRoot == null) {                     logger.warn(\"Web resources not found\");                     return;                 }                  try {                     int innerRootIndex = jarRoot.getPath().indexOf(\"!\/\");                     String path = jarRoot.getPath().substring(0, innerRootIndex);                     jarRoot = new URL(path);                 } catch (Exception e) {                     logger.warn(\"Web resources URL error\", e);                     return;                 }                 context.getResources().createWebResourceSet(ResourceSetType.RESOURCE_JAR,                         \"\/\", jarRoot, \"\/\" + META_INF_RESOURCES);                 logger.info(\"Web resources were added to Tomcat\");             }         }     } } <\/code><\/pre>\n<h3>Mojarra<\/h3>\n<p>\u0412\u044b\u0448\u0435 \u044f \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043b \u0441 Apache MyFaces. \u0415\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Eclipse Mojarra, \u0442\u043e \u0434\u0432\u0435 \u043f\u0440\u0430\u0432\u043a\u0438 \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c.<\/p>\n<p>\u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043d\u0430<\/p>\n<pre><code class=\"xml\">&lt;dependency&gt;     &lt;groupId&gt;org.glassfish&lt;\/groupId&gt;     &lt;artifactId&gt;jakarta.faces&lt;\/artifactId&gt;     &lt;version&gt;4.0.0&lt;\/version&gt; &lt;\/dependency&gt; &lt;dependency&gt; &lt;!-- \u041e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e \u0434\u043b\u044f \u0432\u0435\u0431\u0441\u043e\u043a\u0435\u0442\u043e\u0432 --&gt;     &lt;groupId&gt;org.glassfish&lt;\/groupId&gt;     &lt;artifactId&gt;jakarta.json&lt;\/artifactId&gt;     &lt;version&gt;2.0.0&lt;\/version&gt; &lt;\/dependency&gt; <\/code><\/pre>\n<p>\u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 <code>ServletContainerInitializer<\/code>.<\/p>\n<pre><code class=\"java\">import com.sun.faces.config.FacesInitializer;  ServletContainerInitializer facesInitializer = new FacesInitializer(); facesInitializer.onStartup(null, context); <\/code><\/pre>\n<h3>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c Jakarta Faces \u0432\u043c\u0435\u0441\u0442\u0435 \u0441\u043e Spring Boot \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043a\u0430\u043a \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u044b \u0434\u043b\u044f \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u0441\u0435\u0440\u0432\u043b\u0435\u0442\u043e\u0432.<\/p>\n<p>\u041d\u043e \u0443\u043f\u0430\u043a\u043e\u0432\u043a\u0430 \u0432\u0441\u0435 \u0443\u0441\u043b\u043e\u0436\u043d\u044f\u0435\u0442.<\/p>\n<p>\u0414\u043b\u044f WAR-\u043f\u0430\u043a\u0435\u0442\u0430 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f. \u0422\u043e\u043b\u044c\u043a\u043e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u044b, \u0438 \u0432\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043a\u0430\u043a \u0431\u0443\u0434\u0442\u043e \u0437\u0430\u0434\u0435\u043f\u043b\u043e\u0435\u043d\u043e \u0432 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0439 Tomcat. \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 &#8212; \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u044d\u0442\u043e \u0438\u0437 IDE. \u0417\u0430\u043f\u0443\u0441\u043a main-class DemoApplication \u0438\u0437 IDE &#8212; \u044d\u0442\u043e \u043d\u0435 \u0442\u043e\u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u0447\u0442\u043e \u0437\u0430\u043f\u0443\u0441\u043a<\/p>\n<blockquote>\n<p>java -jar demo.war<\/p>\n<\/blockquote>\n<p>DX \u043f\u043e\u043b\u0443\u0447\u0435\u0442\u0441\u044f \u043f\u043b\u043e\u0445\u0438\u043c.<\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0438\u0442\u0430\u044e \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c JAR. \u0418 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043a\u043b\u0430\u0441\u0442\u044c \u0441\u043d\u0430\u0440\u0443\u0436\u0438 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u0430\u0442\u0430\u043b\u043e\u0433. \u0410 \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0438\u0437 IDE, \u044f \u043c\u043e\u0433\u0443 \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c xhtml, java, \u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432\u0438\u0434\u043d\u044b \u0431\u0435\u0437 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430. \u041d\u0430\u0434\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c.<\/p>\n<h3>\u0421\u0441\u044b\u043b\u043a\u0438<\/h3>\n<ol>\n<li>\n<p><a href=\"https:\/\/jakarta.ee\/specifications\/faces\/4.0\/jakarta-faces-4.0.html\" rel=\"noopener noreferrer nofollow\">Faces specification<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/jakarta.ee\/specifications\/cdi\/4.0\/jakarta-cdi-spec-4.0.html\" rel=\"noopener noreferrer nofollow\">CDI specification<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/jakarta.ee\/specifications\/servlet\/6.0\/jakarta-servlet-spec-6.0.html\" rel=\"noopener noreferrer nofollow\">Servlet specification<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/docs.spring.io\/spring-boot\/docs\/current\/reference\/htmlsingle\/#web\" rel=\"noopener noreferrer nofollow\">Spring Boot<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/eclipse-ee4j\/mojarra\" rel=\"noopener noreferrer nofollow\">Mojarra<\/a><\/p>\n<\/li>\n<\/ol>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/div>\n<p> <!----> <\/p>\n<div class=\"tm-article-poll-container\">\n<div class=\"tm-article-poll tm-article-poll_variant-bordered\">\n<div class=\"tm-notice tm-article-poll__notice tm-notice_positive\"><!----> <\/p>\n<div class=\"tm-notice__inner\"><!----> <\/p>\n<div class=\"tm-notice__content\"><span>\u0422\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u043c\u043e\u0433\u0443\u0442 \u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432 \u043e\u043f\u0440\u043e\u0441\u0435. <a rel=\"nofollow\" href=\"\/kek\/v1\/auth\/habrahabr\/?back=\/ru\/articles\/736474\/&#038;hl=ru\">\u0412\u043e\u0439\u0434\u0438\u0442\u0435<\/a>, \u043f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430.<\/span><\/div>\n<\/div>\n<\/div>\n<div class=\"tm-article-poll__header\">\u0427\u0442\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0438\u0442\u0430\u0435\u0442\u0435?<\/div>\n<div class=\"tm-article-poll__answers\">\n<div class=\"tm-article-poll__answer\">\n<div class=\"tm-article-poll__answer-data\"><span class=\"tm-article-poll__answer-percent\">             0%           <\/span> <span class=\"tm-article-poll__answer-label\">CDI<\/span> <span class=\"tm-article-poll__answer-votes\">             0           <\/span><\/div>\n<div class=\"tm-article-poll__answer-bar\">\n<div class=\"tm-article-poll__answer-progress\" style=\"width:0%;\"><\/div>\n<\/div>\n<\/div>\n<div class=\"tm-article-poll__answer\">\n<div class=\"tm-article-poll__answer-data\"><span class=\"tm-article-poll__answer-percent tm-article-poll__answer-percent_winning\">             100%           <\/span> <span class=\"tm-article-poll__answer-label\">Spring<\/span> <span class=\"tm-article-poll__answer-votes\">             2           <\/span><\/div>\n<div class=\"tm-article-poll__answer-bar\">\n<div class=\"tm-article-poll__answer-progress tm-article-poll__answer-progress_winning\" style=\"width:100%;\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"tm-article-poll__stats\">        \u041f\u0440\u043e\u0433\u043e\u043b\u043e\u0441\u043e\u0432\u0430\u043b\u0438 2 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.           \u0412\u043e\u0437\u0434\u0435\u0440\u0436\u0430\u0432\u0448\u0438\u0445\u0441\u044f \u043d\u0435\u0442.      <\/div>\n<\/div>\n<div class=\"tm-article-poll tm-article-poll_variant-bordered\">\n<div class=\"tm-notice tm-article-poll__notice tm-notice_positive\"><!----> <\/p>\n<div class=\"tm-notice__inner\"><!----> <\/p>\n<div class=\"tm-notice__content\"><span>\u0422\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u043c\u043e\u0433\u0443\u0442 \u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432 \u043e\u043f\u0440\u043e\u0441\u0435. <a rel=\"nofollow\" href=\"\/kek\/v1\/auth\/habrahabr\/?back=\/ru\/articles\/736474\/&#038;hl=ru\">\u0412\u043e\u0439\u0434\u0438\u0442\u0435<\/a>, \u043f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430.<\/span><\/div>\n<\/div>\n<\/div>\n<div class=\"tm-article-poll__header\">\u041a\u0430\u043a \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0435 Spring Boot?<\/div>\n<div class=\"tm-article-poll__answers\">\n<div class=\"tm-article-poll__answer\">\n<div class=\"tm-article-poll__answer-data\"><span class=\"tm-article-poll__answer-percent tm-article-poll__answer-percent_winning\">             100%           <\/span> <span class=\"tm-article-poll__answer-label\">java -jar demo.jar<\/span> <span class=\"tm-article-poll__answer-votes\">             2           <\/span><\/div>\n<div class=\"tm-article-poll__answer-bar\">\n<div class=\"tm-article-poll__answer-progress tm-article-poll__answer-progress_winning\" style=\"width:100%;\"><\/div>\n<\/div>\n<\/div>\n<div class=\"tm-article-poll__answer\">\n<div class=\"tm-article-poll__answer-data\"><span class=\"tm-article-poll__answer-percent\">             0%           <\/span> <span class=\"tm-article-poll__answer-label\">java -jar demo.war<\/span> <span class=\"tm-article-poll__answer-votes\">             0           <\/span><\/div>\n<div class=\"tm-article-poll__answer-bar\">\n<div class=\"tm-article-poll__answer-progress\" style=\"width:0%;\"><\/div>\n<\/div>\n<\/div>\n<div class=\"tm-article-poll__answer\">\n<div class=\"tm-article-poll__answer-data\"><span class=\"tm-article-poll__answer-percent\">             0%           <\/span> <span class=\"tm-article-poll__answer-label\">\u0414\u0435\u043f\u043b\u043e\u0439 \u043d\u0430 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440. Spring Boot \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0441\u043f\u0440\u0438\u043d\u0433\u0430<\/span> <span class=\"tm-article-poll__answer-votes\">             0           <\/span><\/div>\n<div class=\"tm-article-poll__answer-bar\">\n<div class=\"tm-article-poll__answer-progress\" style=\"width:0%;\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"tm-article-poll__stats\">        \u041f\u0440\u043e\u0433\u043e\u043b\u043e\u0441\u043e\u0432\u0430\u043b\u0438 2 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.           \u0412\u043e\u0437\u0434\u0435\u0440\u0436\u0430\u0432\u0448\u0438\u0445\u0441\u044f \u043d\u0435\u0442.      <\/div>\n<\/div>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/736474\/\"> https:\/\/habr.com\/ru\/articles\/736474\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<p>Spring Boot \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 Tomcat Embed. Tomcat \u043d\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 Jakarta Faces \u0438 CDI. \u041d\u0435 \u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u044d\u0442\u043e, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Faces.<\/p>\n<p>\u042d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u043e \u0442\u043e\u043c, \u043a\u0430\u043a\u0430\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u043d\u0443\u0436\u043d\u0430 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 Jakarta Faces \u0432\u043c\u0435\u0441\u0442\u0435 \u0441\u043e Spring Boot. \u0422\u0430\u043a\u0436\u0435 \u044f \u043e\u043f\u0438\u0441\u0430\u043b \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0448\u0438\u0431\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u0442\u044c\u0441\u044f.<\/p>\n<h3>Tomcat<\/h3>\n<p>\u0412 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u044f \u0445\u043e\u0447\u0443 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u043e\u0435 \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441 Jakarta Faces \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0441\u044f \u043d\u0430 \u043f\u043e\u043b\u043d\u043e\u043c Tomcat.<br \/> \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u043b\u0443\u0447\u0430\u044f Mojarra README <a href=\"https:\/\/github.com\/eclipse-ee4j\/mojarra\" rel=\"noopener noreferrer nofollow\">\u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442<\/a> \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u0434\u043b\u044f CDI<\/p>\n<pre><code class=\"xml\">&lt;dependency&gt;     &lt;groupId&gt;org.jboss.weld.servlet&lt;\/groupId&gt;     &lt;artifactId&gt;weld-servlet-shaded&lt;\/artifactId&gt;     &lt;version&gt;4.0.0.Final&lt;\/version&gt; &lt;\/dependency&gt; <\/code><\/pre>\n<p>\u042d\u0442\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 Jakarta API. \u0418 \u044d\u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443. Tomcat \u0443\u0436\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0441 Jakarta API. \u041d\u043e \u043a\u043e\u0434 \u0442\u0430\u043c \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f. \u0412\u043e \u0432\u0440\u0435\u043c\u044f \u0434\u0435\u0431\u0430\u0433\u0430 IDE \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u043d\u0430 \u044d\u0442\u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u0430\u0445. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u044d\u0442\u0438 API \u0438\u0437 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439. \u041c\u043e\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a<\/p>\n<pre><code class=\"xml\">&lt;dependency&gt;     &lt;groupId&gt;org.apache.myfaces.core&lt;\/groupId&gt;     &lt;artifactId&gt;myfaces-impl&lt;\/artifactId&gt;     &lt;version&gt;4.0.0&lt;\/version&gt; &lt;\/dependency&gt; &lt;dependency&gt;     &lt;groupId&gt;jakarta.servlet&lt;\/groupId&gt;     &lt;artifactId&gt;jakarta.servlet-api&lt;\/artifactId&gt;     &lt;version&gt;6.0.0&lt;\/version&gt;     &lt;scope&gt;provided&lt;\/scope&gt; &lt;\/dependency&gt; &lt;dependency&gt;     &lt;groupId&gt;org.jboss.weld.servlet&lt;\/groupId&gt;     &lt;artifactId&gt;weld-servlet-core&lt;\/artifactId&gt;     &lt;version&gt;5.1.0.Final&lt;\/version&gt;     &lt;exclusions&gt;         &lt;exclusion&gt;             &lt;groupId&gt;jakarta.el&lt;\/groupId&gt;             &lt;artifactId&gt;jakarta.el-api&lt;\/artifactId&gt;         &lt;\/exclusion&gt;         &lt;exclusion&gt;             &lt;groupId&gt;jakarta.annotation&lt;\/groupId&gt;             &lt;artifactId&gt;jakarta.annotation-api&lt;\/artifactId&gt;         &lt;\/exclusion&gt;     &lt;\/exclusions&gt; &lt;\/dependency&gt; <\/code><\/pre>\n<p>\u0417\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c <code>weld-servlet-core<\/code> \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u043b\u0438\u0441\u0442\u0435\u043d\u0435\u0440 \u0434\u043b\u044f \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442 CDI. \u0417\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c <code>myfaces-impl<\/code> \u0441\u0430\u043c\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 FacesServlet.<\/p>\n<p>\u041c\u043d\u0435 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440, \u0447\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442.<\/p>\n<pre><code class=\"java\">import java.util.Set;  import jakarta.faces.application.ProjectStage; import jakarta.faces.component.UIInput; import jakarta.servlet.ServletContainerInitializer; import jakarta.servlet.ServletContext; import jakarta.servlet.ServletException; import jakarta.servlet.annotation.WebListener;  @WebListener public class ConfigureListener implements ServletContainerInitializer {      @Override     public void onStartup(Set&lt;Class&lt;?&gt;&gt; classes, ServletContext context) throws ServletException {         context.setInitParameter(UIInput.EMPTY_STRING_AS_NULL_PARAM_NAME, Boolean.TRUE.toString());          context.setInitParameter(ProjectStage.PROJECT_STAGE_PARAM_NAME, ProjectStage.Development.name());     } } <\/code><\/pre>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u0432\u0441\u0435. \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0433\u0443 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c xhtml \u0438 \u0431\u0438\u043d\u044b.<\/p>\n<h3>Spring Boot<\/h3>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c Spring Boot. \u042f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b <a href=\"https:\/\/start.spring.io\/\" rel=\"noopener noreferrer nofollow\">Spring Initializr<\/a> \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f jar-\u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u0441\u043f\u0440\u0438\u043d\u0433\u0430 \u0434\u043b\u044f \u0432\u0435\u0431\u0430:<\/p>\n<pre><code class=\"xml\">&lt;dependency&gt;     &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;     &lt;artifactId&gt;spring-boot-starter-web&lt;\/artifactId&gt; &lt;\/dependency&gt; <\/code><\/pre>\n<p>\u041c\u043e\u0436\u043d\u043e \u0443\u0434\u0430\u043b\u0438\u0442\u044c provided-\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u0434\u043b\u044f servlet api<\/p>\n<pre><code class=\"xml\">&lt;dependency&gt;     &lt;groupId&gt;jakarta.servlet&lt;\/groupId&gt;     &lt;artifactId&gt;jakarta.servlet-api&lt;\/artifactId&gt;     &lt;version&gt;6.0.0&lt;\/version&gt;     &lt;scope&gt;provided&lt;\/scope&gt; &lt;\/dependency&gt; <\/code><\/pre>\n<p>WEBROOT \u0434\u043b\u044f Tomcat embedded &#8212; <code>\/META-INF\/resources<\/code>. \u042f \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u044d\u0442\u0443 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e \u0432 <code>\/src\/main\/resources<\/code>. \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u043e\u0432\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \/src\/main\/resources\/META-INF\/resources\/hello.xhtml<\/p>\n<pre><code class=\"xml\">&lt;!DOCTYPE html&gt; &lt;html     xmlns=\"https:\/\/jakarta.ee\/xml\/ns\/jakartaee\"     xmlns:f=\"jakarta.faces.core\"     xmlns:h=\"jakarta.faces.html\"     xmlns:c=\"jakarta.tags.core\"&gt; &lt;h:head&gt;     &lt;title&gt;Hello World&lt;\/title&gt;     &lt;h:outputScript library=\"js\" name=\"demo.js\" \/&gt; &lt;\/h:head&gt; &lt;h:body&gt;     &lt;h1&gt;Hello World&lt;\/h1&gt;     &lt;h:form id=\"helloForm\"&gt;          &lt;h:inputText id=\"number\"             value=\"#{helloBacking.number}\"             onblur=\"demoLog(event.target.value)\"&gt;         &lt;\/h:inputText&gt;          &lt;h:commandButton id=\"submitBtn\"             value=\"Submit\"             type=\"button\"             action=\"#{helloBacking.submit}\"&gt;             &lt;f:ajax execute=\"@form\" render=\"output messages\" \/&gt;         &lt;\/h:commandButton&gt;          &lt;div&gt;             &lt;h:outputText id=\"output\" value=\"#{helloBacking.number}\" \/&gt;         &lt;\/div&gt;          &lt;h:messages id=\"messages\" showSummary=\"true\" showDetail=\"true\"\/&gt;      &lt;\/h:form&gt; &lt;\/h:body&gt; &lt;\/html&gt; <\/code><\/pre>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u0438\u0434\u0435\u0442\u044c \u0437\u0434\u0435\u0441\u044c \u0441\u043a\u0440\u0438\u043f\u0442<\/p>\n<pre><code class=\"xml\">&lt;h:outputScript library=\"js\" name=\"demo.js\" \/&gt; <\/code><\/pre>\n<p>\u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043e\u043d \u0432 \u0444\u0430\u0439\u043b\u0435 <code>\/META-INF\/resources\/resources\/js\/demo.js<\/code>. \u042f \u0432\u044b\u0437\u044b\u0432\u0430\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>demoLog<\/code> \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u043d\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 blur.<\/p>\n<p>\u0411\u0438\u043d \u0434\u043b\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b:<\/p>\n<pre><code class=\"java\">package com.example.demo.backing;  import jakarta.enterprise.context.SessionScoped; import jakarta.inject.Named;  @Named(value = \"helloWorld\") @SessionScoped public class HelloWorld implements Serializable {     private BigDecimal number;      public void submit() {         System.out.println(this.number);     }      public BigDecimal getNumber() {         return number;     }      public void setNumber(BigDecimal number) {         this.number = number;     } }  <\/code><\/pre>\n<p>\u0415\u0449\u0435 \u0434\u0432\u0430 \u0444\u0430\u0439\u043b\u0430 \u0434\u043b\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0439<\/p>\n<p>\/src\/main\/resources\/META-INF\/beans.xml<\/p>\n<pre><code class=\"xml\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt; &lt;beans     xmlns=\"https:\/\/jakarta.ee\/xml\/ns\/jakartaee\"     xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"     xsi:schemaLocation=\"https:\/\/jakarta.ee\/xml\/ns\/jakartaee         https:\/\/jakarta.ee\/xml\/ns\/jakartaee\/beans_4_0.xsd\"     version=\"4.0\" bean-discovery-mode=\"annotated\" &gt;     &lt;!-- CDI configuration here. --&gt; &lt;\/beans&gt; <\/code><\/pre>\n<p>\/src\/main\/resources\/META-INF\/resources\/WEB-INF\/faces-config.xml<\/p>\n<pre><code class=\"xml\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt; &lt;faces-config     xmlns=\"https:\/\/jakarta.ee\/xml\/ns\/jakartaee\"     xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"     xsi:schemaLocation=\"https:\/\/jakarta.ee\/xml\/ns\/jakartaee         https:\/\/jakarta.ee\/xml\/ns\/jakartaee\/web-facesconfig_4_0.xsd\"     version=\"4.0\" &gt;     &lt;!-- Faces configuration here. --&gt; &lt;\/faces-config&gt; <\/code><\/pre>\n<p>\u0418 \u044d\u0442\u043e \u0432\u0441\u0435 \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<\/p>\n<p>\u0421\u0435\u0440\u0432\u0435\u0440 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043c\u043e\u0439 xhtml. \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043d\u0435\u0442 faces servlet. \u0417\u0434\u0435\u0441\u044c \u043f\u0440\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u0441 Tomcat. \u0421\u043f\u0440\u0438\u043d\u0433\u043e\u0432\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f <a href=\"https:\/\/docs.spring.io\/spring-boot\/docs\/current\/reference\/htmlsingle\/#web.servlet.embedded-container.context-initializer\" rel=\"noopener noreferrer nofollow\">\u043d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442<\/a> \u043a\u043b\u0430\u0441\u0441\u044b <code>jakarta.servlet.ServletContainerInitializer<\/code>. \u042f \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u043f\u0440\u0438\u043d\u0433\u043e\u0432\u044b\u0439 \u0431\u0438\u043d <code>org.springframework.boot.web.servlet.ServletContextInitializer<\/code> \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0438\u0445 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e.<\/p>\n<pre><code class=\"java\">import org.springframework.boot.web.servlet.ServletContextInitializer; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration;  @Configuration public class Config {     @Bean     public ServletContextInitializer jsfInitializer() {         return new JsfInitializer();     } } <\/code><\/pre>\n<p>\u0415\u0441\u0442\u044c \u0434\u0432\u0430 <code>ServletContainerInitializer<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u0434\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c. \u0414\u043b\u044f CDI &#8212; \u044d\u0442\u043e <code>org.jboss.weld.environment.servlet.EnhancedListener<\/code>. \u0414\u043b\u044f MyFaces &#8212; <code>org.apache.myfaces.webapp.MyFacesContainerInitializer<\/code>.<\/p>\n<pre><code class=\"java\">import org.apache.myfaces.webapp.MyFacesContainerInitializer; import org.jboss.weld.environment.servlet.EnhancedListener; import org.springframework.boot.web.servlet.ServletContextInitializer;  import jakarta.faces.application.ProjectStage; import jakarta.faces.component.UIInput; import jakarta.servlet.ServletContainerInitializer; import jakarta.servlet.ServletContext; import jakarta.servlet.ServletException;  public class JsfInitializer implements ServletContextInitializer {      @Override     public void onStartup(ServletContext context) throws ServletException {         context.setInitParameter(UIInput.EMPTY_STRING_AS_NULL_PARAM_NAME, Boolean.TRUE.toString());         context.setInitParameter(ProjectStage.PROJECT_STAGE_PARAM_NAME, ProjectStage.Development.name());          EnhancedListener cdiInitializer = new EnhancedListener();         cdiInitializer.onStartup(null, context);          ServletContainerInitializer myFacesInitializer = new MyFacesContainerInitializer();         myFacesInitializer.onStartup(null, context); } } <\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043d\u043e\u0432\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430. \u0423\u0436\u0435 \u043e\u0442 FacesServlet:<\/p>\n<blockquote>\n<p>Servlet.init() for servlet [FacesServlet] threw exception<br \/> java.lang.IllegalStateException: No Factories configured for this Application. This happens if the faces-initialization does not work at all &#8212; make sure that you properly include all configuration settings necessary for a basic faces application and that all the necessary libs are included. Also check the logging output of your web application and your container for any exceptions!<br \/> If you did that and find nothing, the mistake might be due to the fact that you use some special web-containers which do not support registering context-listeners via TLD files and a context listener is not setup in your web.xml.<br \/> A typical config looks like this;<\/p>\n<\/blockquote>\n<pre><code class=\"xml\">&lt;listener&gt;     &lt;listener-class&gt;         org.apache.myfaces.webapp.StartupServletContextListener     &lt;\/listener-class&gt; &lt;\/listener&gt; <\/code><\/pre>\n<p>\u042d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e Spring \u043d\u0435 \u0441\u043a\u0430\u043d\u0438\u0440\u0443\u0435\u0442 classpath \u043d\u0430 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 servlet-\u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439 \u0438 <code>web-fragment.xml<\/code>. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0434\u043e\u043b\u0436\u0435\u043d \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u0441\u043f\u0440\u0438\u043d\u0433\u043e\u0432\u044b\u0439 \u0431\u0438\u043d \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e <code>Config.java<\/code>.<\/p>\n<pre><code class=\"java\">import org.apache.myfaces.webapp.StartupServletContextListener; import org.springframework.boot.web.servlet.ServletListenerRegistrationBean; import org.springframework.context.annotation.Bean; import jakarta.servlet.ServletContextListener;  @Bean public ServletListenerRegistrationBean&lt;ServletContextListener&gt; facesStartupServletContextListener() {     ServletListenerRegistrationBean&lt;ServletContextListener&gt; bean = new ServletListenerRegistrationBean&lt;&gt;();     bean.setListener(new StartupServletContextListener());     return bean; } <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<\/p>\n<h3>Customize faces config<\/h3>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044e \u0447\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u0432 <code>faces-config.xml<\/code> \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438. \u042f \u0445\u043e\u0447\u0443 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043b\u0443\u0448\u0430\u0442\u0435\u043b\u044f \u0434\u043b\u044f ELContext \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u0432 Java Flight Recorder.<\/p>\n<pre><code class=\"java\">import jdk.jfr.Event; import jdk.jfr.Label; import jdk.jfr.Name;  @Name(\"com.example.faces.EvaluateExpression\") @Label(\"Evaluate Expression\") public class EvaluateExpressionEvent extends Event {  @Label(\"Expression\") private String expression;  public String getExpression() { return expression; }  public void setExpression(String expression) { this.expression = expression; } } <\/code><\/pre>\n<pre><code class=\"java\">import jakarta.el.ELContext; import<\/code><\/pre>\n<p><\/br><\/p>\n<\/blockquote>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-347712","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/347712","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=347712"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/347712\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=347712"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=347712"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=347712"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}