SpringBoot:如何配置特定资源

Nin*_*nja 3 java spring-boot

我有配置文件:开发人员、产品人员。

我的主页位于/src/main/resources/static/index.html

如何用不同的个人资料制作不同的主页?

例如,/src/main/resources/static-dev/index.html/src/main/resources/static-prod/index.html

有什么建议吗?

Nin*_*nja 5

最后我得到了一个简单的解决方案。

使用不同的配置文件application.propertiesapplication-prod.properties.

我为他们每个人配置了不同的资源位置。例如spring.resources.static-locations=classpath:/static-dev/

  • @TanKimLoong我认为这个解决方案已经是[配置文件特定的](https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-profiles.html)。`application-dev.properties` 中的 `spring.resources.static-locations=classpath:/static/,classpath:/static-dev/` 和 `spring.resources.static-locations=classpath:/static/,classpath: “application-prod.properties”中的 /static-prod/`。使用脚本“java -jar -Dspring.profiles.active=prod xxx.jar”运行并激活配置文件 (2认同)