Business operating System (i)

Source: Internet
Author: User
Tags log4j

First, build the development environment 1. Database environment

(1) Create a database.

Create DATABASE Bos Character Set UTF8

(2) Create a database user.

Create user Bos identified by ' 123456 '

(3) Authorization for users

Grant all on bos.* to BOS

(4) Log in to MySQL using the created user

mysql–ubos–p123456

2.WEB Environment

(1) Web. xml

<?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/javaee" xmlns:web= "http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi: schemalocation= "Http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id= "Webapp_ ID "version=" 2.5 "><display-name>bos</display-name><!--filters to resolve deferred load issues--><filter>< Filter-name>opensession</filter-name><filter-class> org.springframework.orm.hibernate3.support.opensessioninviewfilter</filter-class></filter>< Filter-mapping><filter-name>opensession</filter-name><url-pattern>/*</url-pattern> </filter-mapping><!--specifying spring configuration file--><context-param><param-name>contextconfiglocation </param-name><param-value>classpath:applicationcontext.xml</param-value></context-param ><listener><listener-class>org.springframework.web.context.contextloaderlistener</listener-class></listener><!--solve post garbled--><filter>< Filter-name>characterencodingfilter</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></filter> <filter-mapping><filter-name>characterencodingfilter</filter-name><url-pattern>/*</ url-pattern></filter-mapping><!--struts2 Core Filter--><filter><filter-name>struts</ filter-name><filter-class>org.apache.struts2.dispatcher.ng.filter.strutsprepareandexecutefilter</ filter-class></filter><filter-mapping><filter-name>struts</filter-name>< url-pattern>/*</url-pattern><dispatcher>request</dispatcher><!--Server Internal forwarding is also processed by the filter- <dispatcher>forward</dispatcher></filTer-mapping><welcome-file-list><welcome-file>index.html</welcome-file><welcome-file >index.htm</welcome-file><welcome-file>index.jsp</welcome-file><welcome-file> Default.html</welcome-file><welcome-file>default.htm</welcome-file><welcome-file> Default.jsp</welcome-file></welcome-file-list></web-app>

(2) Struts.xml

<?xml version= "1.0" encoding= "UTF-8"? ><! DOCTYPE struts Public "-//apache software foundation//dtd struts Configuration 2.3//en" "http://struts.apache.org/dtds/ Struts-2.3.dtd "><struts><!--Open Development mode--><constant name=" Struts.devmode "value=" true "/>< Package name= "User" extends= "struts-default" ><!--requires permission control of page access--><action name= "page_*_*" >< Result type= "Dispatcher" >/web-inf/pages/{1}/{2}.jsp</result></action></package></struts >

(3) configuration applicationcontext.xml

Data sources, Localsessionfactorybean, transaction managers, component scans, support for spring annotations, transaction annotations support.

<?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:context= "Http://www.springframework.org/schema/context" xmlns:aop= "HTTP://WWW.SPRINGFRAMEWORK.ORG/SCHEMA/AOP" xmlns:tx= "Http://www.springframework.org/schema/tx" xsi: schemalocation= "Http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/ spring-beans.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/ spring-context.xsdhttp://www.springframework.org/schema/aophttp://www.springframework.org/schema/aop/ Spring-aop.xsdhttp://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd " ><!--Load Properties file--><context:property-placeholder location= "classpath:jdbc.properties"/><!--data Source-- ><bean id= "ds" class= "Com.mchange.v2.c3p0.ComboPooledDataSource" ><property name= "Driverclass" value= "$ {Driverclass} "/>&Lt;property name= "Jdbcurl" value= "${jdbcurl}"/><property name= "user" value= "${user}"/><property name= " Password "value=" ${password} "/></bean><!--local session factory Bean for creating sessionfactory--><bean id=" Sessionfactory "class=" Org.springframework.orm.hibernate3.LocalSessionFactoryBean "><property name=" DataSource "ref=" DS "/><!--inject Hibernate related properties--><property name=" Hibernateproperties "><props> <prop key= "Hibernate.dialect" >org.hibernate.dialect.mysql5dialect</prop><prop key= "hibernate.show _sql ">true</prop><prop key=" Hibernate.hbm2ddl.auto ">update</prop></props></ property><!--injection of HBM mapping files--><property name= "Mappingdirectorylocations" ><list><value> classpath:com/kiwi/bos/domain</value></list></property></bean><!--Component Scan-->< Context:component-scan base-package= "Com.kiwi.bos"/><context:annotation-config/><!--transaction manager-->< Bean id= "TxmanAger "class=" Org.springframework.orm.hibernate3.HibernateTransactionManager "><property name=" Sessionfactory "ref=" sessionfactory "/></bean><!--transaction Annotations--><tx:annotation-driven Transaction-manager= "Txmanager"/></beans>

(4) configuration jdbc.properties

Driverclass=com.mysql.jdbc.driver
Jdbcurl=jdbc:mysql:///bos?useunicode=true&characterencoding=utf8
User=admin
password=123456

(5) configuration log4j. Properties

# # Direct log messages to stdout # # #
Log4j.appender.stdout=org.apache.log4j.consoleappender
Log4j.appender.stdout.target=system.err
Log4j.appender.stdout.layout=org.apache.log4j.patternlayout
Log4j.appender.stdout.layout.conversionpattern=%d{absolute}%5p%c{1}:%l-%m%n

# # Direct messages to File MyLog.log # # #
Log4j.appender.file=org.apache.log4j.fileappender
Log4j.appender.file.file=d:/mylog.log
Log4j.appender.file.layout=org.apache.log4j.patternlayout
Log4j.appender.file.layout.conversionpattern=%d{absolute}%5p%c{1}:%l-%m%n

# # # Set Log levels-for more verbose logging "info" to ' Debug ' # # #
# # # Fatal error warn info debug trace
Log4j.rootlogger=info, stdout

Business operating System (i)

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.