A quick tutorial for middleware products

Monday, April 8, 2019

On April 08, 2019 by Kamlesh   No comments
One of the main reason of Spring boot huge success is AutoConfiguration, Developers were really exhausted by this xml configuration.

In traditional spring mvc architecture if you wanted just to configure component scan and views, you had to write below shown snippet.

<context:component-scan base-package="com.example.spring.dao"></context:component-scan>
<context:component-scan base-package="com.example.spring.controllers"></context:component-scan>
<context:component-scan base-package="com.example.spring.services"></context:component-scan>
<mvc:annotation-driven/>
 <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
      <property name="prefix" value="/WEB-INF/jsps/" />
      <property name="suffix" value=".jsp" />
 </bean>

Now,In spring boot it is just two lines of code that needs to be placed in application.properties.


spring.mvc.view.prefix=/WEB-INF/views/
spring.mvc.view.suffix=.jsp
 
So What is application.properties?
It is a YAML configuration file placed under src/main/resources folder,it is a human readable key:value format where you place all the configuration like server port,database information,logging systems etc.


Example : For logging properties

logging.level.org.springframework.web=DEBUG
logging.level.org.hibernate=ERROR

For more examples refer spring boot documentation

0 comments:

Post a Comment