When using Spring + Spring Boot + STS, where in the Spring Project directory is the localhost "home" folder? - spring

I am using Spring/Spring Boot/and Ember. I want to put my index.html file in the "localhost" main folder, but I have no idea how the Spring Tool Suite deploys Spring Boot. What is the normal process for HTML development and accessing a Spring REST server without getting Cross Site Scripting errors?
My folder structure is as follows:
/.settings
/BookingClient
/gradle
/html (this is where my index.html, css, and all Ember related JS stuff is)
/node_modules
/src
/target
I am guessing its somewhere in the /target directory but nothing I have tried has worked.

Spring Boot will serve static resources for you. Simply put them in src/main/resources/static. See the documentation on static content for more information.

Related

How to access resources folder outside of the war in spring boot

I have a rest API written in Spring Boot that has to be deployed on a weblogic server on Unix. I have some property files and DRL files in src/resources folder. I want to place all these files on a Unix location and access them in my application. Is there a way to do this ?
When you want Spring to look outside the project folder you want:
"file:/Users/username/MyDirectory/file.txt"

Cannot locate any file inside templates folder from browser

I've made some thymeleaf templates and want to use it with Spring Boot (on Tomcat) and the only location inside a project where I can find a .html file from browser is src/main/resources/static. When I place a file there, I can access it with contextRoot/filename.html. But when I place it inside src/main/resources/templates folder, I cannot access it with neither of this: root/filename.html, root/resources/filename.html. What's the problem here?
Problem was that I didn't have Spring Boot Thymeleaf Starter dependency in the POM. I had plain Thymeleaf dependency not intended for Spring Boot and using it needed more configuration unlike the first one that works out of the box.

JSPs, static content, SpringBoot jars and IntelliJ

So I'm developing in IntelliJ a spring boot app. Using Gradle, I'm creating the sprint boot jar file.
I'm having problems figuring out where to put the jsps and static content such as .js files in such a way that running the jar AND running from within IntelliJ works!
It seems that in order to get SpringBoot to find jsps in a jar file I need to put the jsps inside a src/main/resources/META-INF/resources directory. For example, META-INF/resources/WEB-INF/index.jsp. I'm pretty sure the WEB-INF is now meaningless.
However, if I try to run this spring boot app from within IntelliJ, it cannot find the jsp. 404, blah blah blah. I actually have to put the jsps in the war-style webapp directory in src/main. However that directory is totally ignored during the spring boot jar build.
So.. how do developers set up their development environments that is both IntelliJ and, say, gradle bootRun friendly?
There is a guide here which should work both in IntelliJ IDEA and in the command line via the war file which can be executed as a jar (via java -jar).
As per spring boot there are Limitations when it comes to jsp's.
To overcome these limitations we need to have the configuration made in the application to render jsp by placing the jsp's under src/main/resources/META-INF/resources/WEB-INF/jsp folder.
Sample Code: Click Here
References:
https://dzone.com/articles/spring-boot-with-jsps-in-executable-jars-1
https://github.com/hengyunabc/spring-boot-fat-jar-jsp-sample

Springboot finds files in src/main/webapp but not src/main/webapp/anything

I'm using Sprint boot to run a web application. I did not configure any classes explicitly. I have a strange problem. When running the web server using gradle bootRun, I am able to access files that are directly under webapp folder but not a sub-folder like webapp/something.
I'm not posting any code here because there is nothing explicitly I configured different from a default spring boot web app. I'm using structure as in https://github.com/jhipster/jhipster-sample-app-gradle
Anyone faced this problem before ?

Proper place to put static resources in my Spring Boot project

In my Spring Boot project I cannot get static resources such as css, images and java script file via web browser. Where is proper place to put whole bootstrap dictionary, or how to configure to get desired resources?
Just create static folder in src/main/resources here: https://github.com/bajdekm/MailingHero/tree/master/src/main/resources and place them all there. If you don't create controller with mapping to root resource (something like #RequestMapping("/")), spring boot will serve static content from index.html automatically.
Here is relevant section of Spring Boot documentation.

Resources