SpringBootJarが機能しない場合

Spring BootJarの読み込みの問題のトラブルシューティング



画像







新しいSpringBootアーカイブを開始する際に問題が発生しましたか?







一般的に、この方向での革新は最初ではなく、特別な基準はありません。したがって、多くの人が問題をつかみ、フォーラムやスタックのオーバーフローで問題を解決します。

あなたも問題に遭遇した場合、私はあなたがそれを解決するのを手伝います。この場合、読み進めてください。







, BootJar . , .







. — JSP . JSP? , - , , .







( ):







/src/main/
    java/
    resources/
        static/
            some.html
        public/
    webapp/
        WEB-INF/jsp
            index.jsp
      
      





BootJar / BootWar, jsp BootJar . BootWar. , . , — , , , . BootRun , .







, : , .







, . BootJar. , … ! , 302 + 404 ( ). .

— , , , webjars. ???







. jsp BootJar, BootWar. … . , .







, . BootJar — . .







: Spring Boot , . — . ! .







. — BootJar (webjars), , , , , ! , .







— - static/, public/. , . jsp . , . , ( ), jsp . jsp ,

spring.resources.static-locations









.

, , , . , ( webapp/), , , — META-INF/resources, . BootJar. .







? -, -, , . — . , . , .







-? -, , , -, . , . , : — , , .







. . , , classpath.







, . ?







.







  1. spring- . , , , jsp .
  2. . : spring-, , — , , . , .
  3. — BootJar.


. , , .

Gradle.

.







sourceSets {
    jsp {
        resources.source(sourceSets.main.resources);
        resources.srcDirs += ['src/main/webapp'];
    }
    jmh {
        .. ..
    }
}
      
      











task jsp(type: Jar, description: 'JSP Packaging') {
    archiveBaseName = 'jsp'
    group = "build"
    def art = sourceSets.jsp.output
    from(art) {
        exclude('META-INF')
        into('META-INF/resources/')
    }
    from(art) {
        include('META-INF/*')
        into('/')
    }
    dependsOn(processJspResources)
}
      
      





processJspResources , . :







bootJar {
    dependsOn(jsp)
    bootInf.with {
        from(jsp.archiveFile) {
            include('**/*.jar')
        }
        into('lib/')
    }
}
      
      





別の方法(直接)で追加する方法が見つかりませんでした-依存関係によっては、プロジェクト自体のjspImplementation構成を接続することはできませんが、接続したいと思います。しかし、それでも別のモジュールから取得する場合は、次のようにします。







artifacts {
    jspImplementation jsp
}
      
      





これで、リソースlibができました。これは、すべての標準に従って、tomkatをロードする必要があり、ロードされます。BootJarのように実行します。








All Articles