简体   繁体   English

集成FF4j的Spring Boot REST应用程序。 如何修复依赖库的MVC映射?

[英]Spring boot REST application integrating FF4j. How to fix mvc mapping for dependent library?

Integrating FF4j in my application I've got a queue of issues. FF4j集成到我的应用程序中时,我遇到了很多问题。 Its integrated finally following recommendation . 最后综合其建议 Short description of recommendation is: 推荐的简短描述是:

  • Remove auto-configuration of thymeleaf; 删除百里香叶的自动配置;
  • Add the old thymeleaf version 2.1.4.RELEASE which is used by ff4j-web 添加ff4j-web使用的旧百里香叶2.1.4.RELEASE版本
  • Write a configuration class like FF4JWebConfiguration: 编写类似FF4JWebConfiguration的配置类:

     @Configuration @ConditionalOnClass({ConsoleServlet.class, FF4jDispatcherServlet.class}) @AutoConfigureAfter(FF4JConfiguration.class) public class FF4JWebConfiguration extends SpringBootServletInitializer { @Bean public ServletRegistrationBean servletRegistrationBean(ConsoleServlet ff4jConsoleServlet) { return new ServletRegistrationBean(ff4jConsoleServlet, "/ff4j-console"); } @Bean @ConditionalOnMissingBean public ConsoleServlet getFF4jServlet(FF4j ff4j) { ConsoleServlet ff4jConsoleServlet = new ConsoleServlet(); ff4jConsoleServlet.setFf4j(ff4j); return ff4jConsoleServlet; } @Bean public ServletRegistrationBean ff4jDispatcherServletRegistrationBean(FF4jDispatcherServlet ff4jDispatcherServlet) { return new ServletRegistrationBean(ff4jDispatcherServlet, "/ff4j-web-console/*"); } @Bean @ConditionalOnMissingBean public FF4jDispatcherServlet getFF4jDispatcherServlet(FF4j ff4j) { FF4jDispatcherServlet ff4jConsoleServlet = new FF4jDispatcherServlet(); ff4jConsoleServlet.setFf4j(ff4j); return ff4jConsoleServlet; } 

    } }

Missed detail in recommendation is maven exclusion: 建议中遗漏的细节是行家排除法:

<dependency>
  <groupId>org.thymeleaf</groupId>
  <artifactId>thymeleaf</artifactId>
  <version>2.1.4.RELEASE</version>
  <exclusions>
    <exclusion>
      <artifactId>javassist</artifactId>
      <groupId>org.javassist</groupId>
    </exclusion>
  </exclusions>
</dependency>

But it isn't work 但这是行不通的

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 
14:11:33.605 ERROR o.s.b.SpringApplication - Application run failed 
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.boot.archive.spi.ArchiveException: Could not build ClassFile
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1745)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:576)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:498)
  at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
  at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)

until I've added some maven exclusion tricks 直到我添加了一些Maven排除技巧

<dependency>
  <groupId>org.thymeleaf</groupId>
  <artifactId>thymeleaf</artifactId>
  <version>2.1.4.RELEASE</version>
  <exclusions>
    <exclusion>
      <artifactId>javassist</artifactId>
      <groupId>org.javassist</groupId>
    </exclusion>
  </exclusions>
</dependency>

my application successfully launched with corrupted view because of some data doesn't load on ui: 由于某些数据未在ui上加载,我的应用程序成功以损坏的视图启动了:

13:38:14.785 INFO  o.f.w.FF4jServlet -   __  __ _  _   _
13:38:14.785 INFO  o.f.w.FF4jServlet -  / _|/ _| || | (_)
13:38:14.785 INFO  o.f.w.FF4jServlet - | |_| |_| || |_| |
13:38:14.785 INFO  o.f.w.FF4jServlet - |  _|  _|__   _| |
13:38:14.785 INFO  o.f.w.FF4jServlet - |_| |_|    |_|_/ |
13:38:14.786 INFO  o.f.w.FF4jServlet -              |__/  v1.8
13:38:14.786 INFO  o.f.w.FF4jServlet -
13:38:14.832 INFO  o.f.w.FF4jServlet - Thymeleaf has been initialized
13:38:14.887 INFO  o.t.TemplateEngine - [THYMELEAF] INITIALIZING TEMPLATE ENGINE
                  13:38:14.971 INFO  o.t.t.AbstractTemplateResolver - [THYMELEAF] INITIALIZING TEMPLATE RESOLVER: org.thymeleaf.templateresolver.ClassLoaderTemplateResolver
13:38:14.972 INFO  o.t.t.AbstractTemplateResolver - [THYMELEAF] TEMPLATE RESOLVER INITIALIZED OK
                  13:38:14.980 INFO  o.t.T.CONFIG - [THYMELEAF] TEMPLATE ENGINE CONFIGURATION:
[THYMELEAF] * Cache Factory implementation: org.thymeleaf.cache.StandardCacheManager
[THYMELEAF] * Template modes:
[THYMELEAF]     * VALIDXML
[THYMELEAF]     * XHTML
[THYMELEAF]     * LEGACYHTML5
[THYMELEAF]     * XML
[THYMELEAF]     * VALIDXHTML
[THYMELEAF]     * HTML5
[THYMELEAF] * Template resolvers (in order):
[THYMELEAF]     * org.thymeleaf.templateresolver.ClassLoaderTemplateResolver
[THYMELEAF] * Message resolvers (in order):
[THYMELEAF]     * [0] customMessageResolver
[THYMELEAF] * Dialect: org.thymeleaf.standard.StandardDialect
[THYMELEAF]     * Prefix: "th"
[THYMELEAF] TEMPLATE ENGINE CONFIGURED OK
13:38:14.981 INFO  o.t.TemplateEngine - [THYMELEAF] TEMPLATE ENGINE INITIALIZED
13:38:15.648 INFO  o.a.c.c.C.[.[.[/] - Initializing Spring DispatcherServlet 'dispatcherServlet'
13:38:15.649 INFO  o.s.w.s.DispatcherServlet - Initializing Servlet 'dispatcherServlet'
13:38:15.713 INFO  o.s.w.s.DispatcherServlet - Completed initialization in 64 ms
13:38:15.746 WARN  o.s.w.s.PageNotFound - No mapping for GET /static/css/font-awesome-3.2.1.css
13:38:15.747 WARN  o.s.w.s.PageNotFound - No mapping for GET /static/css/bootstrap.min.css
13:38:15.747 WARN  o.s.w.s.PageNotFound - No mapping for GET /static/js/jquery/jquery-1.9.1.js
13:38:15.749 WARN  o.s.w.s.PageNotFound - No mapping for GET /static/css/dashboard.css
13:38:15.749 WARN  o.s.w.s.PageNotFound - No mapping for GET /static/css/style.css
13:38:15.750 WARN  o.s.w.s.PageNotFound - No mapping for GET /static/css/bootstrap-responsive.min.css
13:38:15.972 WARN  o.s.w.s.PageNotFound - No mapping for GET /static/js/base.js
13:38:15.973 WARN  o.s.w.s.PageNotFound - No mapping for GET /static/js/bootstrap.js
13:38:15.981 WARN  o.s.w.s.PageNotFound - No mapping for GET /static/img/ff4j.png
13:38:15.989 WARN  o.s.w.s.PageNotFound - No mapping for GET /static/img/flags/flagEnglish.png
13:38:15.989 WARN  o.s.w.s.PageNotFound - No mapping for GET /static/js/ff4j.js
13:38:16.016 WARN  o.s.w.s.PageNotFound - No mapping for GET /static/img/flags/flagMexico.png
13:38:16.030 WARN  o.s.w.s.PageNotFound - No mapping for GET /static/img/flags/flagFrance.png
13:38:16.031 WARN  o.s.w.s.PageNotFound - No mapping for GET /static/img/flags/flagGermany.png
13:38:16.032 WARN  o.s.w.s.PageNotFound - No mapping for GET /static/img/flags/flagJapanese.png 
...

it can be fixed with 可以用

registry.addResourceHandler("/static/**")
    .addResourceLocations("classpath:/static/");

But ff4j servlets don't work in my application any way: 但是ff4j servlet无法以任何方式在我的应用程序中运行:

WARN  o.s.w.s.PageNotFound - No mapping for GET /features

Question

I've detected that FF4jServlet initialized and registered all required controllers but I'm not clear why it doesn't work... Is any ideas how to fix it? 我检测到FF4jServlet初始化并注册了所有必需的控制器,但是我不清楚为什么它不起作用...是否有任何解决办法?

Some project details: 一些项目细节:

<parent>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-parent</artifactId>
  <version>2.1.2.RELEASE</version>
  <relativePath/> <!-- lookup parent from repository -->
</parent>

<ff4j.version>1.8.0</ff4j.version>

Have you tried to look at 你试过看看吗

https://github.com/ff4j/ff4j-spring-boot-starter-parent/tree/master/ff4j-spring-boot-sample ? https://github.com/ff4j/ff4j-spring-boot-starter-parent/tree/master/ff4j-spring-boot-sample吗?

There are two consoles. 有两个控制台。 Which one are you trying to access ? 您想访问哪一个?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在我的Spring Boot Rest应用程序和json mysql中,onetoone映射不起作用 - onetoone Mapping is not working in my spring boot rest application and json mysql 休息控制器没有映射在Spring Boot - Rest controller not mapping in spring boot 在 Spring Boot 应用程序中使用 web3j java 库时,我在 Web3j.build 行中收到以下异常。 任何想法来解决这个问题? - When using web3j java library in a spring boot application, I am getting the below exception in the Web3j.build line. Any idea to fix this issue? 如何使用mongodb应用程序在spring boot中修复UnsatisfiedDependencyException? - How to fix UnsatisfiedDependencyException in spring boot with mongodb application? 如何在Spring Boot REST应用程序中重用类? - How to reuse classes in a Spring Boot REST application? 如何将 Firebase 与 Spring Boot REST 应用程序一起使用? - How to use Firebase with Spring boot REST Application? Spring 启动 - 如何在 rest 应用程序中验证 Multipartfile - Spring boot - How to validate Multipartfile in rest application 如何创建Jar库文件,该文件自动为Spring Boot应用程序创建rest api端点? - How to create Jar library file which automatically creates rest api endpoints to a spring boot application? spring 引导项目中的 FF4J 配置错误 - Error with FF4J configuration in spring boot project 在 Spring Boot 应用程序中集成 Apache guacamole - Integrating Apache guacamole in spring boot application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM