Skip to main content

Posts

Showing posts with the label MVC

SpringBoot : What are Profiles in Spring Boot Application

What are Profiles in Spring Boot Profiles can be seen as different environments in spring boot application. Suppose you are working on an application where you have different staging environments like Dev, QA, UAT, Production etc. So you will have different configurations for each environment, for this kind of applications what you need is having different values that can be switched depending upon some flags. In early days, people used to write configurations for all environments and comment the unused environments. But with Spring Boot we can do this without commenting any code by use of Profiles . Suppose we have database name configurations for our application as follows Dev     - ekiras_dev QA    - ekiras_qa UAT  - ekiras_uat Prod  - ekiras Now, we can use profiling in this case. How we will do it ? lets see Creating Profiles in Spring Boot  We will create different files for different environments and call then as profile in rest of the blog...

SpringBoot : How to display static html file in Spring boot MVC application

Points To Remember In order to serve static files like js, css, images etc ,all your files should be under the resources/static folder. Spring application can serve all the static files inside folders resources/static/ resources/public/ In order to serve html files from spring boot application  your html files should be under static/public folder you need to add view controller to serve html file How to display static html file in Spring boot MVC application Step 1 : Extend Class WebMvcConfigurerAdapter You should create a class that extends WebMvcConfigurerAdapter Your class should have  @Configuration annotation. You class should not have  @EnableMvc annotation. Override addViewControllers method and add your mapping. Override configurePathMatch method and update suffix path matching. view plain copy to clipboard print ? @Configuration    public   class  MvcConfigurer  extends  WebMvcConfigurerAdapter {      ...