Springブートのドキュメントによれば、static
フォルダ内のリソースは、追加の構成や要求マッピングなしでSpringブートによって自動的に提供されます。私はここでhttp://localhost:8080/js/filter.js
Springブートで静的リソースにアクセスできない
に行くことによってjavascriptのファイルにアクセスしようとしています
は春のドキュメントのその部分のそのセクションのスクリーンショットです。ここで
私の現在のresources
のディレクトリ構造のスクリーンショットです。ここで
私は、最新の春のブートリリースを使用していることを示すために私のpom.xml
です。
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>velocity-demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>velocity-demo</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
<version>1.7</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
は、ここで私は@PostMapping("/foo")
に@PostMapping
を変え、私のコントローラでは、私のApplicationクラス
package com.example
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class VelocityDemoApplication {
public static void main(String[] args) {
SpringApplication.run(VelocityDemoApplication.class, args);
}
}
あなたが表示するものは問題ありません。この問題はおそらくあなたのSpring設定の何かによって引き起こされます。あなたはそのすべてを見せてもらえますか? – davidxxx
これ以上の設定はありません。 Applicationクラスを投稿に追加しますが、バニラクラスです。 – qbolt
確かに。それはむしろ単純です。しかし、それは**すべての**ですか?私はちょうどテストして、それは動作します。 – davidxxx