设置外部Webapp目录

时间:2019-04-24 08:03:04

标签: spring spring-boot jsf

我有一个Spring-boot Webapp,我想将其部署为jar。但是它也应该解析某些网页(xhtml)。我可以将其部署为.war文件。但是我们需要将它们彼此独立地部署。

该网站本身包含JSF组件,当我尝试访问该页面时,出现一条消息javax.enterprise.resource.webcontainer.jsf.application : JSF1064: Unable to find or serve resource。搜索此内容,仅提供了一些JSF事实,这些事实无法解决我的问题。我认为核心问题只是Springboot应用程序找不到webroot。

可能是我失明还是使用错误的搜索模式,但是如何告诉spring-boot在已知的类路径或已知的静态文件夹之外提供网站服务?

我尝试将其设置为

spring:
  mvc:
    static-path-pattern: /var/www/webapp

也为

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry){
        registry.addResourceHandler("/**")
                .addResourceLocations("/var/www/webapp/")
                .setCachePeriod(0);
    }

但是没有任何作用。


已解决..

我用过

@Component
public class CustomContainer implements WebServerFactoryCustomizer<ConfigurableServletWebServerFactory> {
  @Override
  public void customize(ConfigurableServletWebServerFactory factory) {
      factory.setDocumentRoot(new File("/var/www/webapp/")); 
  }
}

它应该很简单...

0 个答案:

没有答案
相关问题