Wenn Ihr Spring BootJar nicht funktioniert

Fehlerbehebung beim Laden von Spring Boot Jar



Bild







Haben Sie das Problem beim Starten eines neuen Spring Boot-Archivs festgestellt?







Im Allgemeinen ist Innovation in diese Richtung nicht die erste, es gibt keine besonderen Standards. Daher harken viele Leute Probleme und lösen sie in Foren und stapeln Überläufe.

Wenn Sie auch auf ein Problem stoßen, helfe ich Ihnen bei der Lösung. In diesem Fall lesen Sie weiter.







, 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/')
    }
}
      
      





Ich konnte nicht finden, wie ich es auf andere Weise hinzufügen kann (direkt) - es ist unmöglich, die jspImplementation-Konfiguration des Projekts selbst abhängig von den Abhängigkeiten zu verbinden, aber ich möchte. Aber wenn wir es immer noch von einem anderen Modul nehmen, dann machen wir das immer noch:







artifacts {
    jspImplementation jsp
}
      
      





Das war's, jetzt haben wir eine Ressourcenbibliothek, die der Tomkat nach allen Standards laden muss und die er lädt. Führen Sie es wie BootJar aus.








All Articles