Building Schneider Building Control system Database Backend Server example project-(project creation)

Source: Internet
Author: User
Tags aop

Work in the Schneider Building control system to add the background management functions and mobile phone control functions, unit procurement of Schneider's products is only used to control the field equipment Building control module and host computer programming and HMI, we need on this basis, independent development of mobile phone-side control functions, Then you need to create a background project to signal to Schneider's hardware, or modify its database.

This article is based on this idea, documenting how to use Spring, Hibernate, and rest as a framework to build a quick-to-develop background management framework.

1. Create a common Java project using eclipse


2. Right-click the project name, select Properties, tap "Project Facets" to tick "Dynamic Web module"


3. Copy all the jar files required for spring, Hibernate, and rest to the Web-inf/lib folder of the Web project (it is recommended that you copy the jar file to the project instead of the reference, otherwise you will need to place a jar package under Tomcat. Otherwise it will be run as the Times wrong)

4. New Web. XML for configuring spring information

<?xml version= "1.0" encoding= "UTF-8"? ><web-app xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance" xmlns= "Http://java.sun.com/xml/ns/j2ee" xmlns:javaee= "Http://java.sun.com/xml/ns/javaee" xmlns:web= "http// Java.sun.com/xml/ns/javaee/web-app_2_5.xsd "xsi:schemalocation=" HTTP://JAVA.SUN.COM/XML/NS/J2EE/http Java.sun.com/xml/ns/j2ee/web-app_2_4.xsd "version=" 2.4 "><display-name>taccontrolserverweb</ Display-name><distributable/><context-param><param-name>contextconfiglocation</ Param-name><param-value> Classpath:/spring/applicationcontext*.xml </param-value></con Text-param><filter><filter-name>encodingfilter</filter-name><filter-class> Org.springframework.web.filter.characterencodingfilter</filter-class><init-param><param-name >encoding</param-name><param-value>utf-8</param-value></init-param><init-param ><param-name>forceEncoding</param-name><param-value>true</param-value></init-param></filter><filter-mapping ><filter-name>encodingfilter</filter-name><url-pattern>/*</url-pattern></ filter-mapping><listener><!--Automatic assembly of ApplicationContext configuration information--><listener-class> Org.springframework.web.context.contextloaderlistener</listener-class></listener><listener> <!--Org.springframework.web.util.IntrospectorCleanupListener Listener is primarily responsible for handling buffer leaks caused by the use of JavaBean Introspector <listener-class>org.springframework.web.util.introspectorcleanuplistener</listener-class></ listener><listener><!--Contextloaderlistener implements the Servletcontextlistener listener interface, The Servletcontextlistener is only responsible for monitoring the startup and shutdown events of the Web container. The Requestcontextfilter implements the Servletrequestlistener listener interface, which listens for HTTP request events and notifies the listener every time a request is received by the Web server. The Requestcontextfilter,spring container is more closely combined with the Web container by configuring it. --><listener-class>org.springframework.web.context.request.requestcontextlistener</listener-class></listener><!--Rest Listener configuration--><servlet><display-name>jax-rs rest servlet </display-name><servlet-name>jax-rs REST servlet</servlet-name><servlet-class> com.sun.jersey.spi.spring.container.servlet.springservlet</servlet-class><init-param>< param-name>com.sun.jersey.config.property.packages</param-name><param-value>szx.rest</ param-value></init-param><load-on-startup>1</load-on-startup></servlet>< Servlet-mapping><servlet-name>jax-rs REST servlet</servlet-name><url-pattern>/szxrest/*< /url-pattern></servlet-mapping><servlet><description></description><display-name >FindInfo</display-name><servlet-name>FindInfo</servlet-name><servlet-class> Szx.web.servlet.findinfo</servlet-class></servlet><servlet-mapping><servlet-name> findinfo</servlet-name><url-pattern>/findinfo</url-pattern></servlet-mapping><welcome-file-list><welcome-file>index.jsp</ Welcome-file></welcome-file-list></web-app>
5. After spring is configured, hibernate information and auto-injection are configured in the spring configuration file as follows Applicationcontext-core.xml

<?xml version= "1.0" encoding= "UTF-8"? ><beans xmlns= "Http://www.springframework.org/schema/beans" xmlns: Xsi= "Http://www.w3.org/2001/XMLSchema-instance" xmlns:aop= "Http://www.springframework.org/schema/aop" xmlns: context= "Http://www.springframework.org/schema/context" xmlns:jee= "Http://www.springframework.org/schema/jee" xmlns:tx= "Http://www.springframework.org/schema/tx" xsi:schemalocation= "http://www.springframework.org/schema/ beanshttp://www.springframework.org/schema/beans/spring-beans-2.5.xsdhttp://www.springframework.org/schema/ aophttp://www.springframework.org/schema/aop/spring-aop-2.5.xsdhttp://www.springframework.org/schema/ contexthttp://www.springframework.org/schema/context/spring-context-2.5.xsdhttp://www.springframework.org/ schema/jeehttp://www.springframework.org/schema/jee/spring-jee-2.5.xsdhttp://www.springframework.org/schema/ Txhttp://www.springframework.org/schema/tx/spring-tx-2.5.xsd "><context:property-placeholder location=" Classpath:jdbc.properties "/&GT;&LT;bean id= "DataSource" class= "Org.apache.commons.dbcp.BasicDataSource" destroy-method= "Close" ><property name = "Driverclassname" value= "${jdbc.driverclassname}"/><property name= "url" value= "${jdbc.url}"/>< Property name= "username" value= "${jdbc.username}"/><property name= "password" value= "${jdbc.password}"/> <property name= "maxactive" value= "/><property name=" Maxidle "value=" ></property>< Property Name= "Maxwait" value= "25000"/><property name= "Poolpreparedstatements" value= "false"/>< Property Name= "Defaultautocommit" value= "true"/></bean><!--Hibernate sessionfactory--><bean id= " Sessionfactory "class=" Org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean ">< Property Name= "DataSource" ref= "DataSource"/><property name= "Packagestoscan" ><list><value> Szx</value></list></property><property name= "Hibernateproperties" ><value>hiberNate.dialect=${hibernate.dialect}hibernate.query.substitutions=true ' Y ', false ' N ' Hibernate.cache.use_second_ Level_cache=truehibernate.cache.provider_class=org.hibernate.cache.ehcacheproviderhibernate.jdbc.fetch_size= 50hibernate.jdbc.batch_size=25hibernate.show_sql=truehibernate.format_sql=falsehibernate.use_sql_comments=true </value></property><property name= "Lobhandler" ref= "Lobhandler"/></bean><bean id= " Lobhandler "class=" Org.springframework.jdbc.support.lob.OracleLobHandler "><property name=" NativeJdbcExtractor "ref=" NativeJdbcExtractor "/></bean><bean id=" NativeJdbcExtractor "class=" Org.springframework.jdbc.support.nativejdbc.CommonsDbcpNativeJdbcExtractor "/><!--Transaction Manager for a Single Hibernate sessionfactory--><bean id= "TransactionManager" class= " Org.springframework.orm.hibernate3.HibernateTransactionManager "><property name=" sessionfactory "ref=" Sessionfactory "/></bean><!--Enable Annotation-basEd configuration--><context:annotation-config/><!--Enable classpath Scanning for managed components-- ><context:component-scan base-package= "SZX" name-generator= "Szx.core.spring.CustomBeanNameGenerator"/> <!--enable @AspectJ support--><aop:aspectj-autoproxy/><!--enable @Transactional support--&GT;&LT;TX : Annotation-driven/><aop:config><aop:advisor advice-ref= "Txadvice" pointcut= "Execution (* *). service.*manager.* (..)) " order= "/></aop:config><tx:advice id=" Txadvice "><tx:attributes><tx:method name=" * " Rollback-for= "Throwable"/></tx:attributes></tx:advice></beans>
6. Create a new Jdbc.properties file and configure the database connection (database can be adapted to MySQL, Oracle, SQL Server)

#hibernate. dialect=cn.walle.core.support.hibernate.oracle10gdialecthibernate.dialect= org.hibernate.dialect.sqlserverdialect#jdbc.driverclassname=oracle.jdbc.driver.oracledriver# jdbc.driverclassname=com.microsoft.jdbc.sqlserver.sqlserverdriver#jdbc.url=jdbc:sqlserver://localhost:1433; Integratedsecurity=true;databasename=taclogdatajdbc.driverclassname=net.sourceforge.jtds.jdbc.driverjdbc.url= Jdbc:jtds:sqlserver://localhost:1433;integratedsecurity=true;databasename=taclogdata#jdbc.url=jdbc:oracle:thin : @192.168.103.9:1521:orcl#jdbc.url=jdbc:oracle:thin:@219.237.193.91:1521:orcl#jdbc.url=jdbc:oracle:thin:@ Iwmds.rdh.com:1521:orcljdbc.username=tacvistajdbc.password=tacvista
7. Engineering structures such as






Building Schneider Building Control system Database Backend Server example project-(project creation)

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.