Spring BOOT statische Ressourcen-Zuordnung

Ich weiß, diese Frage ist oft zu Fragen, aber nichts davon funktioniert bei mir.
Ich möchte den Zugriff auf die statischen Ressourcen, also ich habe ein template, in dem ich load "../resources/css/style.css".

Aber wenn ich die Anwendung starten Sie den browser keinen Zugriff auf die css-Datei.

Ich bin mit Spring Boot 1.1.9 (auch als Elternteil in pom.xml).

Meine Struktur ist:

pom.xml

src/main/java

src/main/resources

src/main/resources/database

src/main/resources/templates

src/main/resources/templates/index.html

src/main/resources/static

src/main/resources/static/Ressourcen

src/main/resources/static/resources/css

src/main/resources/static/resources/fonts

src/main/resources/static/resources/img

src/main/resources/static/resources/js

(siehe http://i62.tinypic.com/of84jt.png)

Mein Controller:

package prototype.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
public class IndexController {

  @RequestMapping("/")
  public String stdRedirect(){
    return "redirect:/index";
  }

  @RequestMapping(value="/index", method=RequestMethod.GET)
  public String index(){
    return "index";
  }
}

Main:

@Configuration
@EnableAutoConfiguration
@ComponentScan
public class Prototype {
  public static void main(String[] args) throws Exception {
    SpringApplication.run(Prototype.class, args);
  }
}    

Habe ich gelesen, dass springboot automatische Karten /static/und /Ressourcen-Dateien...

  • Bitte posten Sie einige Protokolle und einige Konfigurations - (pom.xml, Anwendung, Zusammenhang, wenn Sie haben) auf pastebin und verlinke Sie hier.
  • pastebin pom.xml Startup-log
  • Ich bin nicht eine Spring-Boot-Experte, weil ich mich mit Spring framework manuell, aber vielleicht ist es, weil Sie einen eigenen Java-Konfigurator. Ich fand diese main-Klasse für die Verwendung von Spring boot: github.com/spring-projects/spring-boot/blob/v1.1.9.RELEASE/... Sie sollten erweitern SpringBootServletInitializer
  • Sie müssen nur verlängern SpringBootServlrtInitializer wenn Sie einen Krieg und der Bereitstellung in einem servlet-container
InformationsquelleAutor laserbeamer | 2014-11-12
Schreibe einen Kommentar