Skip to main content

Posts

Showing posts with the label Spring-boot

Spring boot: configure it to find the webapp folder

See the docs:  http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-developing-web-applications.html#boot-features-spring-mvc-static-content The static resources are loaded from  /static ,  /public ,  /resources ,  /META-INF/resources Using  src/main/webapp  is not recommended. You can customize that by overriding the  addResourceHandlers  method in  WebMvcConfigurerAdapter @Configuration public class MvcConfig extends WebMvcConfigurerAdapter { @Override public void addResourceHandlers ( ResourceHandlerRegistry registry ){ registry . addResourceHandler ( "/**" ) . addResourceLocations ( "/" ) . setCachePeriod ( 0 ); } } http://stackoverflow.com/questions/28725635/spring-boot-configure-it-to-find-the-webapp-folder

Spring annotation

In Spring 2.0 and later, the @Repository annotation is a marker for any class that fulfills the role or stereotype (also known as Data Access Object or DAO) of a repository. Among the uses of this marker is the automatic translation of exceptions. Spring 2.5 introduces further stereotype annotations: @Component, @Service, and @Controller. @Component is a generic stereotype for any Spring-managed component. @Repository, @Service, and @Controller are specializations of @Component for more specific use cases, for example, in the persistence, service, and presentation layers, respectively. Therefore, you can annotate your component classes with @Component, but by annotating them with @Repository, @Service, or @Controller instead, your classes are more properly suited for processing by tools or associating with aspects. For example, these stereotype annotations make ideal targets for pointcuts. Thus, if you are choosing between using @Component or @Service for your service layer, @S...