Construction of the Schneider Building Control System database backend server example project 2 (database query and writing), Schneider Control System

Source: Internet
Author: User

Construction of the Schneider Building Control System database backend server example project 2 (database query and writing), Schneider Control System

The example Project (Project Creation) of the database backend server of the Schneider building control system records how a Spring, Hibernate, and Rest project is created, this article briefly introduces how to use annotation programming in this framework.

1. Spring Annotation

Spring provides @ Service and @ Autowired annotations for automatic Bean creation in the project.

In our framework, we need to add the @ Service tag before the class name that needs to be called by other classes, and add @ Autowired to the member class that needs to be automatically created, in this way, Spring automatically assembles related class instances for us during the program running.


2. Rest comments

Rest means that we can use "/" to access our background services on the Web end in the form of resource list, rest annotations include @ Get, @ Post, and @ Put, which correspond to the doGet, doPost, and doPut methods in the Servlet respectively, and the annotation for configuring the Rest access Path @ Path

(Ps: In this project, the Rest is automatically created by the Spring framework when the program is running, so you also need to add the @ Service tag)

@ Path ("testRest") @ Servicepublic class TestRest {@ Autowiredprivate TestService testService; @ GET @ Path ("test") public String test () {DuplicateValueTypeModel model = testService. getId (1); return "rest (" + model. getDuplicateValueTypeId () + "," + model. getName () + ")";}}

The Rest access path of the code above is:


The project has not been fully organized yet. Only the database query is implemented, and the code will be improved later. The prototype of the code will be put here first.


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.