Commit a5b2ff08 by BrianHolsen

'init'

parents
# Created by https://www.gitignore.io/api/maven,eclipse,intellij+iml
### Eclipse ###
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath
.recommenders
# External tool builders
.externalToolBuilders/
#mac os
.DS_Store
# Locally stored "Eclipse launch configurations"
*.launch
# PyDev specific (Python IDE for Eclipse)
*.pydevproject
# CDT-specific (C/C++ Development Tooling)
.cproject
# Java annotation processor (APT)
.factorypath
# PDT-specific (PHP Development Tools)
.buildpath
# sbteclipse plugin
.target
# Tern plugin
.tern-project
# TeXlipse plugin
.texlipse
# STS (Spring Tool Suite)
.springBeans
# Code Recommenders
.recommenders/
# Scala IDE specific (Scala & Java development for Eclipse)
.cache-main
.scala_dependencies
.worksheet
### Eclipse Patch ###
# Eclipse Core
.project
# JDT-specific (Eclipse Java Development Tools)
.classpath
### Intellij+iml ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff:
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/dictionaries
# Sensitive or high-churn files:
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.xml
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
# Gradle:
.idea/**/gradle.xml
.idea/**/libraries
# CMake
cmake-build-debug/
# Mongo Explorer plugin:
.idea/**/mongoSettings.xml
## File-based project format:
*.iws
## Plugin-specific files:
# IntelliJ
/out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
### Intellij+iml Patch ###
# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023
*.iml
modules.xml
.idea/misc.xml
*.ipr
### Maven ###
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
# Avoid ignoring Maven wrapper jar file (.jar files are usually ignored)
!/.mvn/wrapper/maven-wrapper.jar
# End of https://www.gitignore.io/api/maven,eclipse,intellij+iml
/.idea
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.bbdtek.test</groupId>
<artifactId>proj-test</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spring.version>4.3.3.RELEASE</spring.version>
<javax.servlet.version>3.1.0</javax.servlet.version>
<mybatis.version>3.4.4</mybatis.version>
<!--mysql驱动不能为6.0+否则activiti不自动创建表-->
<mysql.version>5.1.42</mysql.version>
<mongodb.version>1.9.3.RELEASE</mongodb.version>
<redisClient.version>2.9.0</redisClient.version>
<springRedis.version>1.7.4.RELEASE</springRedis.version>
<oa-common.version>0.0.1-SNAPSHOT</oa-common.version>
</properties>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>${javax.servlet.version}</version>
<scope>provided</scope>
</dependency>
<!-- Spring -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- mysql -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.version}</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.1.0.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.3.5.Final</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package com.bbdtek.test.controller;
import org.omg.CORBA.INTERNAL;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
import org.springframework.validation.Errors;
import org.springframework.validation.FieldError;
import org.springframework.validation.ObjectError;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
import org.springframework.validation.Validator;
import java.util.List;
/**
* Created by BrianHolsen on 2017-08-02 at 16:14.
*/
@RequestMapping("/test")
@RestController
public class TestController {
//@Autowired
//private Validator validator = new org.springframework.validation.beanvalidation.LocalValidatorFactoryBean();
@Autowired
private JdbcTemplate jdbcTemplate;
@RequestMapping("hi")
public String hi() {
return "HI!";
}
@RequestMapping("createTable")
public String createTable() {
this.jdbcTemplate.execute("CREATE TABLE DATA (ID INT PRIMARY KEY , NAME VARCHAR(50))");
return "OK";
}
@RequestMapping("generateData")
public String generateData() {
int count = 0;
count += this.jdbcTemplate.update("INSERT INTO DATA(ID,NAME) VALUES(1,\"BRIAN\")");
count += this.jdbcTemplate.update("INSERT INTO DATA(ID,NAME) VALUES(2,\"HOLSEN\")");
return "res: " + count;
}
@RequestMapping("getById")
public String getById(int id) {
String name = this.jdbcTemplate.queryForObject("SELECT NAME FROM DATA WHERE ID=" + id, String.class);
if (name == null) {
return "NOT FOUND";
} else {
return "name is: " + name;
}
}
}
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://mysql/mysql_database?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull
jdbc.username=root
jdbc.password=root
#\u521d\u59cb\u5316\u8fde\u63a5
jdbc.initialSize=10
#\u6700\u5927\u8fde\u63a5\u6570\u91cf\uff0c\u8bbe\u7f6e\u4e3a0\u65f6\uff0c\u8868\u793a\u6ca1\u6709\u9650\u5236
jdbc.maxActive=50
#\u6700\u5927\u7a7a\u95f2\u8fde\u63a5\uff0c\u8bbe\u7f6e\u4e3a0\u65f6\uff0c\u8868\u793a\u6ca1\u6709\u9650\u5236
jdbc.maxIdle=50
#\u6700\u5c0f\u7a7a\u95f2\u8fde\u63a5
jdbc.minIdle=1
#\u8d85\u65f6\u7b49\u5f85\u65f6\u95f4\u4ee5\u6beb\u79d2\u4e3a\u5355\u4f4d 6000\u6beb\u79d2/1000\u7b49\u4e8e60\u79d2\uff0c\u8bbe\u7f6e\u4e3a-1\u8868\u793a\u65e0\u9650\u7b49\u5f85
jdbc.maxWait=60000
#\u4ece\u6570\u636e\u6e90\u4e2d\u8fd4\u56de\u7684\u8fde\u63a5\u662f\u5426\u91c7\u7528\u81ea\u52a8\u63d0\u4ea4\u673a\u5236
jdbc.defaultAutoCommit=true
#\u662f\u5426\u81ea\u6211\u4e2d\u65ad
jdbc.removeAbandoned=true
#\u51e0\u79d2\u540e\u6570\u636e\u8fde\u63a5\u4f1a\u81ea\u52a8\u65ad\u5f00\uff0c\u5728removeAbandoned\u4e3atrue\u65f6\uff0c\u63d0\u4f9b\u8be5\u503c
jdbc.removeAbandonedTimeout=60
#\u8fde\u63a5\u88ab\u6cc4\u9732\u65f6\u662f\u5426\u6253\u5370\uff0c\u9ed8\u8ba4false
jdbc.logAbandoned=false
#\u9a8c\u8bc1\u4ece\u8fde\u63a5\u6c60\u53d6\u51fa\u7684\u8fde\u63a5
jdbc.validationQuery=SELECT 1
#\u662f\u5426\u5728\u4ece\u6c60\u4e2d\u53d6\u51fa\u8fde\u63a5\u524d\u8fdb\u884c\u68c0\u9a8c\uff0c\u8bbe\u7f6e\u4f4dtrue\u65f6\uff0cvalidationQuery\u5fc5\u987b\u4e3a\u975e\u7a7a\u5b57\u7b26\u4e32\uff0c\u9ed8\u8ba4\u4e3atrue
jdbc.testOnBorrow=true
\ No newline at end of file
<?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:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p" xmlns:cache="http://www.springframework.org/schema/cache"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/cache
http://www.springframework.org/schema/cache/spring-cache-3.1.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd ">
<!--<message>Spring公共配置</message>-->
<!-- 引入jdbc配置 -->
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:jdbc/jdbc.properties</value>
<!--要是有多个配置文件,只需在这里继续添加即可 -->
</list>
</property>
<property name="ignoreUnresolvablePlaceholders" value="true" />
</bean>
<!-- spring-mybatis -->
<!--<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">-->
<!--&lt;!&ndash; 使用properties来配置 &ndash;&gt;-->
<!--<property name="driverClassName" value="${jdbc.driver}"/>-->
<!--<property name="url" value="${jdbc.url}"/>-->
<!--<property name="username" value="${jdbc.username}"/>-->
<!--<property name="password" value="${jdbc.password}"/>-->
<!--<property name="initialSize" value="${jdbc.initialSize}"/>-->
<!--<property name="maxActive" value="${jdbc.maxActive}"/>-->
<!--<property name="maxIdle" value="${jdbc.maxIdle}"/>-->
<!--<property name="maxWait" value="${jdbc.maxWait}"/>-->
<!--<property name="defaultAutoCommit" value="${jdbc.defaultAutoCommit}"/>-->
<!--<property name="removeAbandoned" value="${jdbc.removeAbandoned}"/>-->
<!--<property name="removeAbandonedTimeout" value="${jdbc.removeAbandonedTimeout}"/>-->
<!--<property name="logAbandoned" value="${jdbc.logAbandoned}"/>-->
<!--<property name="validationQuery" value="${jdbc.validationQuery}"/>-->
<!--<property name="testOnBorrow" value="${jdbc.testOnBorrow}"/>-->
<!--</bean>-->
<!--<bean id="myBatisTransactionManager"-->
<!--class="org.springframework.jdbc.datasource.DataSourceTransactionManager">-->
<!--<qualifier value="myBatisTransactionManager"/>-->
<!--<property name="dataSource" ref="dataSource" />-->
<!--</bean>-->
<!--<bean id="myBatisSqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">-->
<!--<property name="dataSource" ref="dataSource" />-->
<!--<property name="mapperLocations" value="classpath:mybatis/mappers/**/*.xml"/>-->
<!--<property name="configLocation" value="classpath:mybatis/config.xml" />-->
<!--</bean>-->
<!--<bean id="myBatisScanner" class="org.mybatis.spring.mapper.MapperScannerConfigurer">-->
<!--<property name="basePackage" value="com.bbdtek.oa.framework.**.dao"/>-->
<!--<property name="sqlSessionFactoryBeanName" value="myBatisSqlSessionFactory" />-->
<!--</bean>-->
<!-- 配置事务管理的注解方式注入 -->
<!--<tx:annotation-driven transaction-manager="myBatisTransactionManager"/>-->
<!-- 引入redis配置 -->
<!--<import resource="classpath:redis/config.xml" />-->
<!-- 引入mongo配置 -->
<!--<import resource="classpath:mongo/config.xml" />-->
<bean id="ds" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="${jdbc.driver}"/>
<property name="url" value="${jdbc.url}"/>
<property name="username" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
</bean>
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource" ref="ds"></property>
</bean>
</beans>
\ No newline at end of file
<?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:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<mvc:annotation-driven />
<!-- 自动扫描组件,排除@Controller组件,该组件由SpringMVC配置文件扫描 -->
<!-- 静态资源(js、image等)的访问 -->
<mvc:default-servlet-handler />
<!-- 使用注解的包,包括子集 -->
<!--<context:component-scan base-package="com.bbdtek.oa.framework" />-->
<!--<context:component-scan base-package="com.bbdtek.oa.module.doc" />-->
<context:component-scan base-package="com.bbdtek.test" />
<!-- 视图解析器 -->
</beans>
\ No newline at end of file
<?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"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<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>
<display-name>Archetype Created Web Application</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<!-- 防止发生java.beans.Introspector内存泄露,应将它配置在ContextLoaderListener的前面 -->
<listener>
<listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class>
</listener>
<!-- 监听器,自动装配Spring -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/springmvc.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment