Миграция Spring MVC на Spring boot 2.2.6 - конфигурация плиток не загружается - PullRequest
1 голос
/ 25 мая 2020

Я перенес Spring MVC 5.2.5 в Spring Boot 2.2.6. В проекте много JSP страниц и Apache плиток для создания шаблонов.

Класс приложения Spring выглядит так:

The Pom.xml dependecies are:

test
war


    
        org.springframework.boot
        spring-boot-starter-web
    
    
        org.springframework.boot
        spring-boot-starter-tomcat
    

    
        org.apache.tomcat.embed
        tomcat-embed-jasper
        9.0.35
    
    
        org.apache.tiles
        tiles-extras
        3.0.8
    
    
        org.springframework
        spring-context
    
    
        org.springframework
        spring-webmvc
    
    
        org.springframework
        spring-tx
    
    
        org.springframework
        spring-core
    
    
        javax.servlet.jsp
        javax.servlet.jsp-api
        provided
    
    
        javax.servlet
        jstl
    
    
        org.apache.tiles
        tiles-api
        3.0.8
    
    
        javax.servlet
        javax.servlet-api
        provided
    
    
        cglib
        cglib
    
    
        org.apache.tiles
        tiles-core
    
    
        org.apache.tiles
        tiles-extras
    
    
        org.apache.tiles
        tiles-api
    
    
        org.apache.tiles
        tiles-jsp
    
    
        com.fasterxml.jackson.core
        jackson-core
    
    
        com.fasterxml.jackson.core
        jackson-annotations
    
    
        com.fasterxml.jackson.core
        jackson-databind
    
    
        com.thoughtworks.xstream
        xstream
    
    
        org.springframework.boot
        spring-boot-starter-security
        ${spring.boot.version}
    
    
        com.google.guava
        guava
    
    
        org.springframework.security
        spring-security-taglibs
    
   
    
        com.fasterxml.jackson.datatype
        jackson-datatype-hibernate5
    
    
        org.aspectj
        aspectjweaver
    
    
        org.apache.logging.log4j
        log4j-web
    
    
        commons-fileupload
        commons-fileupload
    

The WebConfiguration class:

   @Configuration
   @EnableWebMvc
   @EnableAspectJAutoProxy
   @Slf4j
   @EnableSwagger2
   public class WebConfiguration implements WebMvcConfigurer
  {
    @Autowired
    private CommonConstants commonConstants;

    @Autowired
    private RestInterceptor restInterceptor;

    @Autowired
    private ObjectMapper objectMapper;

    @Autowired
    private ApplicationContext applicationContext;
    
    @Override
    public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
        configurer.enable();
    }
    
    @Override
    public void configureAsyncSupport(AsyncSupportConfigurer configurer) {
        configurer.setDefaultTimeout(120*1000L);
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        ResourceHandlerRegistration handler = registry.addResourceHandler("/resources/**");
        try {
            if (StringUtils.hasText(commonConstants.getBflowResourceDir())) {
                for (String location 
         Arrays.asList(StringUtils.split(commonConstants.getBflowResourceDir(), ","))) {
                    log.info("Using custom directory for resources: " + location);
                    handler.addResourceLocations("file:" + location + "/");
                }
            }

            handler.addResourceLocations("/dist/");
            }
        catch (Exception e) {
            log.error("error", e);
        }

        handler.addResourceLocations("/WEB-INF/dist/");
    }

    @Bean
    public TilesConfigurer tilesConfigurer() {
        TilesConfigurer tilesConfigurer = new TilesConfigurer();

        String[] definitions = new String[] {"WEB-INF/tiles.xml"};
        tilesConfigurer.setDefinitions(definitions);
        tilesConfigurer.setCheckRefresh(true);

        return tilesConfigurer;
    }

    @Bean
    public TilesViewResolver tilesViewResolver() {
        TilesViewResolver tilesViewResolver = new TilesViewResolver();
        tilesViewResolver.setOrder(-1);
        return tilesViewResolver;
    }
}

The tiles configuration file:

    <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE tiles-definitions PUBLIC
        "-//Apache Software Foundation//DTD Tiles Configuration 3.0//EN"
        "tiles-config_3_0.dtd">            

Сервер успешно запущен, и я получаю просмотры со страниц JSP. Тем не менее, конфигурация плиток не загружена, страница без верхнего и нижнего колонтитула.

Что мне не хватает?

Спасибо за помощь

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...