Spring 3.2.1+proxool +mysql空白專案搭建
阿新 • • 發佈:2019-01-08
lib目錄jar包列表
applicationContent.xml
<?xml version="1.0" encoding="UTF-8"?> <beans default-lazy-init="true" 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:tx="http://www.springframework.org/schema/tx" xmlns:task="http://www.springframework.org/schema/task" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.2.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd "> <!-- 自動掃描 --> <context:component-scan base-package="org.kingschan.ac"></context:component-scan> <!-- 用註解來實現事務管理 --> <tx:annotation-driven transaction-manager="transactionManager" /> <bean id="dataSource" class="org.logicalcobwebs.proxool.ProxoolDataSource"> <property name="driver"> <value>${jdbc.driverClassName}</value> </property> <property name="driverUrl"> <value>${jdbc.url}</value> </property> <property name="delegateProperties"> <value>user=${jdbc.username},password=${jdbc.password}</value> </property> <property name="user"> <value>${jdbc.username}</value> </property> <property name="password"> <value>${jdbc.password}</value> </property> <property name="alias"> <value>${jdbc.alias}</value> </property> <property name="prototypeCount"> <value>${jdbc.prototypeCount}</value> </property> <property name="maximumConnectionCount"> <value>${jdbc.maximumConnectionCount}</value> </property> <property name="minimumConnectionCount"> <value>${jdbc.minimumConnectionCount}</value> </property> <property name="trace"> <value>${jdbc.trace}</value> </property> <property name="verbose"> <value>${jdbc.verbose}</value> </property> <property name="maximumActiveTime"> <value>${jdbc.maximumActiveTime}</value> </property> </bean> <bean id="jdbctemplate" class="org.springframework.jdbc.core.JdbcTemplate"> <property name="dataSource"> <ref bean="dataSource"/> </property> </bean> <!-- 配置JDBC事務管理器 --> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource"> <ref bean="dataSource"/> </property> </bean> <!-- spring的屬性載入器,載入properties檔案中的屬性 --> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>classpath:db.properties</value> </list> </property> <property name="fileEncoding" value="utf-8" /> </bean> <!-- 啟動Spring MVC的註解功能--> <mvc:annotation-driven/> <!-- 檢視解釋類 begin--> <!-- exposeRequestAttributes,exposeSessionAttributes 是請求和會話屬性都被複制到模板的屬性集中, 可以使用FreeMarker的表示式語言來訪問並顯示。 exposeSpringMacroHelpers使用這些巨集 --> <bean id="viewResolver" class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver"> <property name="cache" value="true" /> <property name="prefix" value=""/> <property name="suffix" value=".html" /> <property name="contentType" value="text/html;charset=UTF-8"></property> <property name="requestContextAttribute" value="request" /> <property name="exposeSpringMacroHelpers" value="true" /> <property name="exposeRequestAttributes" value="true" /> <property name="exposeSessionAttributes" value="true" /> <property name="allowSessionOverride" value="true" /> </bean> <bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer"> <property name="templateLoaderPath" value="/WEB-INF/page/flt" /> <property name="freemarkerSettings"> <props> <prop key="template_update_delay">0</prop> <prop key="default_encoding">UTF-8</prop> <prop key="number_format">0.##########</prop> <prop key="datetime_format">yyyy-MM-dd HH:mm:ss</prop> <prop key="classic_compatible">true</prop> <prop key="template_exception_handler">ignore</prop> </props> </property> </bean> <!-- 檢視解釋類 end--> </beans>
WEB.xml
db.properties:<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <servlet> <servlet-name>dispatcherServlet</servlet-name> <servlet-class> org.springframework.web.servlet.DispatcherServlet </servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value> classpath*:dispatch-servlet.xml </param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>dispatcherServlet</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <login-config> <auth-method>BASIC</auth-method> </login-config> <!-- spring --> <listener> <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class> </listener> <!--spring 監聽器--> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/classes/applicationContext.xml</param-value> </context-param> <!-- Filter 定義 --> <!-- Character Encoding filter --> <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> </web-app>
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://UGEY2B73QSJNNX6:3306/sms
#jdbc.url=jdbc:mysql://localhost:3306/sms
jdbc.username=root
jdbc.password=xxxxxx
#jdbc.password=foshancgt
jdbc.alias=pdb
jdbc.houseKeepingSleepTime=10000
jdbc.prototypeCount=5
jdbc.maximumConnectionCount=10000
jdbc.minimumConnectionCount=2
jdbc.maximumActiveTime=54000
jdbc.trace=false
jdbc.verbose=false
jdbc.houseKeepingTestSql=select 1
jdbc.simultaneousBuildThrottle=20