2

I have a UI project structure which uses AngularJS, Bootstrap, and all other 3rd party libraries. Below is the structure:

UI Project Structure

Here 'ui' is the root folder and 'app' is the immediate child of 'ui'. 'App' has 'app/dependencies' for all 3rd party libraries and 'app/modules' for all application AngularJS modules. 'App/index.html' is the main page of the application where all the modules will be rendered accordingly. Each JavaScript is loaded using 'requirejs' configuration and this whole setup is tested with Grunt/Livereload.

The Requirement is, I would like to place this entire 'ui/app' structure in a SpringBoot appication and serve it from there.

I have tried this but spring boot is always looking into the 'template' and 'static' directory. My directory structure and the relative dependencies in the HTML are not loading.

1 Answer 1

1

You can teach Spring Boot to look in other locations, check the documentation for more details

If I understood your structure, the following should work:

spring.resources.static-locations=classpath:/ui/app/

If you want to still serve stuff from staticor public, you'll have to reference those again, something like

spring.resources.static-locations=classpath:/ui/app/,classpath:/static/,classpath:/public/
Sign up to request clarification or add additional context in comments.

4 Comments

I have tried that suggestion by placing the above structure in the src/main/resource and add the spring.resources.static-locations=classpath:/ui/app/
As per above suggestion, Placed the structure in the src/main/resource & added the config. I am getting error: Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'static-locations' of bean class [org.springframework.boot.autoconfigure.web.ResourceProperties]: Bean property 'static-locations' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
It's a 1.3 feature. You're probably using 1.2. There should be a way to make that work in 1.2 with a bit of extra config though.
Yes I am using 1.2.7.RELEASE. Then let me try with 1.3 and get back to you. Thank you for helping me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.