Код: Выделить всё
├── frontend
│ ├── dist
│ | ├── app.js
│ | ├── vendor.js
│ | ├── style.css
│ | ├── index.html
│ ├── node_modules
│ ├── src
│ ├── package.json
│ ├── pom.xml
├── site
│ ├── src
│ ├── pom.xml
< /code>
frontendspring:
profiles: development
resources:
static-locations:
- file:../frontend/dist/
< /code>
All works just fine. But when I add spring-boot-devtools into the site project classpath I get 404 for any file inside dist< /code> папка. < /p>
http://localhost:8080/ -> 404
http://localhost:8080/app.js -> 404
< /code>
Again, no devtools - no problem.
Also if I replace static-locations with addResourceHandlers it works too (no matter with or without devtools).
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/**")
.addResourceLocations("file:/full/path/to/frontend/dist/");
}
< /code>
Is this a devtools bug or my fault?
UPDATE:
Ok thanks to @AndyWilkinson I've figured out the cause of the problem. I work in IntelliJ and use run configurations to set env variables. Here is the resulting command line:
/usr/lib/jvm/java-8-oracle/bin/java -bla-bla-bla -Didea.version=2017.1.3 -T 2 -Dspring.profiles.active=dev spring-boot:run
< /code>
But if devtools is in the project classpath Spring Boot ignores them:
Could not find key 'spring.profiles.active' in any property source
No active profile set, falling back to default profiles: default
< /code>
Now if I simply remove devtools from pom.xml
The following profiles are active: dev
Activated profiles dev
< /code>
... wow, it works again.
The possible workaround is to set active profile directly through application.yml.
spring:
profiles:
active: dev
---
spring:
profiles: dev
resources:
static-locations:
- file:../frontend/dist/
< /code>
.. but i don't like it because it's inconvenient.
So because devtools is such a pain I think I'll prefer to use F5 as before.
Подробнее здесь: https://stackoverflow.com/questions/446 ... h-devtools