• Step-by-Step XML Free Spring MVC 3 Configuration--reference


    The release of Spring 2.5 reduce the burden of XML by introduction annotation based configuration, but you still needed to bootstrap Spring in XML. However in Servlet 3 and Spring 3.1 we can now drop XML completely and have 100% code based configuration. All thanks to the Servlet 3 specification.

    So lets see today how you can create Spring MVC application XML Free.

    Step-by-Step Guide

    Step 1) Create a Enterprise Java project in Eclipse and include Spring v3.1+ jars.

    Step 2) Create a class which implements spring WebApplicationInitializer and override onStartup() method.
    Inside onStartup() method, instantiate AnnotationConfigWebApplicationContext class and set ServletContext. We also need to set a base package name of your configuration files.

    Step 3) Next step is to configure Spring MVC. I do that in following class.
    @EnableWebMvc annotation used together with @Configuration enables default Spring MVC configuration, equivalent to . With @ComponentScan annotation we make sure our @Controller will be added to the application context. The configuration class also defines one @Bean: our default view resolver.

    Step 4) Now create a simple Controller to see whether its working fine or Not.

    Output

    I really like this configuration changes in Spring MVC. It is easy to bootstrap the application with no xml files in place. Of course, this is not everything that Spring MVC 3 brings to the developers. With all the configuration in code it is so easy to refactor and navigate. No more back and forth with XML For more feature of spring mvc, please keep visiting TechZoo.

    Happy Coding :)

    reference from:http://www.techzoo.org/spring-framework/step-by-step-xml-free-spring-mvc-3-configuration.html

  • 相关阅读:
    ERROR Invalid input of type: 'bool'. Convert to a bytes, string, int or float first.
    python2中正则通过全部中文字符
    查询正在执行的SQL
    dataguard 备库删除已应用过的过期归档
    linux lrzsz上传下载
    /u01/app/11.2.0.4/grid/perl/bin/perl -I/u01/app/11.2.0.4/grid/perl/lib -I/u01/app/11.2.0.4/grid/crs/install /u01/app/11.2.0.4/grid/crs/install/rootcrs.pl execution failed
    重启网卡提示Bringing up interface eth0 Device eth0 does not seem to be present,delaying initialization [FAILED]
    rhel 7 RAC安装执行root.sh遭遇ohasd failed to start,Failed to start the Clusterware. Last 20 lines of the alert log follow
    Error in invoking target 'agent nmhs' of makefile...MK_EMAGENT_NMECTL修正
    oracle 11g RAC由非归档修改成归档
  • 原文地址:https://www.cnblogs.com/davidwang456/p/3653376.html
Copyright © 2020-2023  润新知