Use Spring to quickly build Web applications (supporting RESTful APIs) and springrestful

Source: Internet
Author: User
Tags maven central

Use Spring to quickly build Web applications (supporting RESTful APIs) and springrestful

Spring is a good framework ...... However, a common problem in Java development is that the preliminary configuration is too troublesome. There was a new project on hand. After thinking about it, I decided to use Java to do it. I saw the new Spring 4 and Spring Boot, so I could quickly make a Web Demo. However, I do not like the method of using a lot of annotations, and Spring 4 is not coming out for a long time, so I still plan to use Spring 3 for it.

Spring 3 has many configurations. Many articles on the Internet will teach you how to build an environment step by step. All the details are included. Another unpleasant thing is that some concepts are unclear and unfriendly to people who use them for the first time. In addition, I have a poor memory and don't want to start a new project and learn it again from the beginning. So I made a Maven archetype and put it on Github, the name is spring-webapp-restful-quickstart. As the name suggests, in addition to Web Support, RESTful APIs are also supported, just like this:

  • Http: // localhost: 8080/index
    This is HTML page output.
  • Http: // localhost: 8080/index. json
    This is the output of JSON data.

The above two outputs only depend on the URL suffix, and the same Controller is used internally. You do not need to write Controller for the API separately.

The API output uses ContentNegotiatingViewResolver. Currently, the API only supports JSON output, but it is not difficult to add other formats, such as XML. Just change the configuration in applicationContext. xml.

This skeleton uses Tiles 2 as the template, and Tiles 2 is selected because it uses JSP as the basic language, which can be better used with other tag libraries, in addition, it is easier for people familiar with Java to expand. Just make your own JSP tag. Why not choose Tiles 3 ...... It is because I can see that the features of Tiles 2 are enough, so I didn't look at Tiles 3 again ...... In addition, if Jetty is configured, maven jetty: run can be used to run the project.

Currently, this archetype type is only available in my Github, and will be released to the Maven central repository after improvement. You only need to clone git and install it in the local maven repository using Maven install. Select spring-webapp-restful-quickstart when creating a new project using maven.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.