2015-02-07 5 views
0

저는 다중 모듈 스프링 부트 프로젝트를 개발 중입니다. 내 프로젝트 구조는봄 부팅시 부두 구성

  • MyProject를 (부모)
  • 프론트 엔드
    • SRC/메인/자원
      • 프론트 엔드
        • index.html을 같이
    • /자바
      • com.example
        • MyWebApp.java
      • com.example.config
        • WebAppConfig.java
    • 나머지
      • SRC/주
  • 내가 어떤 가치 contextPath로 설정하고 내 인덱스를 실행할 수 있도록 ResourceBase하는

    @Bean 
    public JettyServerCustomizer customizeJettyServer() 
    { 
        return new JettyServerCustomizer() 
        { 
    
         @Override 
         public void customize(final Server server) 
         { 
          ContextHandler frontEndContext = new ContextHandler(); 
          frontEndContext.setContextPath(""); //what should be here 
          frontEndContext.setResourceBase("");//what should be here 
          ResourceHandler frontEndResourceHandler = new ResourceHandler(); 
          frontEndResourceHandler.setWelcomeFiles(new String[] { "index.html" }); 
          frontEndContext.setHandler(frontEndResourceHandler); 
          ContextHandlerCollection contexts = new ContextHandlerCollection(); 
          contexts.setHandlers(new Handler[] { frontEndContext}); 
          server.setHandler(contexts); 
         } 
        }; 
    } 
    

    을 다음과 같은 WebAppConfig에서 빈으로 JettyServerCustomizer을 주입하여 부두를 구성하려고

은 프런트 엔드 모듈에있는 .html? URL은 어떻게 생겼을까요?

감사합니다 :)

답변

1

봄 부팅 할 수 serve static content을 당신을 위해. Jetty를 구성하는 대신 정적 콘텐츠를 src/main/resources/static 아래에 배치하면 클래스 경로에서 곧바로로드됩니다.

+0

'./gradlew bootRun'을 사용하여 응용 프로그램을 실행할 때 true이지만 JAR 배포시 src/main/resources/static 폴더가 아니기 때문에 독립형 jar를 빌드 할 때 정적 내용의 위치를 ​​지정하는 방법 너의 계급에 거기 있니? – user320599

+0

특정 폴더가 classpath에 없지만'static' 폴더와 그 내용은 빌드 시스템이 jar 파일에 포함시키는 것과 같습니다. –

관련 문제