Construction of Schneider Building control system Database Backend Server example project-(project creation) records how a spring, Hibernate, and Rest project is created, this article will briefly describe how to use annotation programming in this framework.
1.Spring comments
Spring provides us with @service, @Autowired these annotations to automate the creation of beans in your project.
In our framework, we need to add a @service tag to each class name that needs to be called by another class, add @autowired on the member class that needs to be created automatically, and spring will automatically assemble the relevant class instance for us at run time.
2.Rest comments
Rest is that we can use the "/" in a resource list to access our backend services on the web side, rest annotations have @get, @Post, @Put corresponding to the servlet in the Doget, DoPost, Doput method, It also has annotations for configuring the Rest access path @path
(PS: Because rest is also created automatically by the spring framework when the program is running in this project, you also need to add @service tags)
@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 to the above code is:
The project has not been fully organized, only to achieve the database query, followed by the completion of the code, the first place the code in this.
Building Schneider Building Control system Database Backend Server example Project II (database query writing)