Java操作数据库Spring(2)

pom.xml

<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/maven-v4_0_0.xsd">  
  <modelVersion>4.0.0</modelVersion>  
  <groupId>TestDataBaseGroup2</groupId>  
  <artifactId>TestDataBaseArt2</artifactId>  
  <packaging>war</packaging>  
  <version>1.0-SNAPSHOT</version>  
  <name>TestDataBaseArt Maven Webapp</name>  
  <url>http://maven.apache.org</url>  
  <dependencies>  
    <dependency>  
      <groupId>junit</groupId>  
      <artifactId>junit</artifactId>  
      <version>4.12</version>  
      <scope>test</scope>  
    </dependency>  
    <!-- oracle -->  
    <dependency>  
      <groupId>com.oracle</groupId>  
      <artifactId>ojdbc6</artifactId>  
      <version>11.2.0</version>  
    </dependency>  
    <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->  
    <dependency>  
      <groupId>mysql</groupId>  
      <artifactId>mysql-connector-java</artifactId>  
      <version>6.0.5</version>  
    </dependency>  
    <!-- spring -->  
    <dependency>  
      <groupId>org.springframework</groupId>  
      <artifactId>spring-webmvc</artifactId>  
      <version>4.3.4.RELEASE</version>  
    </dependency>  
    <dependency>  
      <groupId>org.springframework</groupId>  
      <artifactId>spring-orm</artifactId>  
      <version>4.3.4.RELEASE</version>  
    </dependency>  
    <dependency>  
      <groupId>org.springframework</groupId>  
      <artifactId>spring-aspects</artifactId>  
      <version>4.3.4.RELEASE</version>  
    </dependency>  
    <dependency>  
      <groupId>org.springframework</groupId>  
      <artifactId>spring-test</artifactId>  
      <version>4.3.4.RELEASE</version>  
    </dependency>  
    <!-- https://mvnrepository.com/artifact/org.springframework/spring-context -->  
    <dependency>  
      <groupId>org.springframework</groupId>  
      <artifactId>spring-context</artifactId>  
      <version>4.3.4.RELEASE</version>  
    </dependency>  
    <!-- https://mvnrepository.com/artifact/org.springframework.data/spring-data-jpa -->  
    <dependency>  
      <groupId>org.springframework.data</groupId>  
      <artifactId>spring-data-jpa</artifactId>  
      <version>1.10.6.RELEASE</version>  
    </dependency>  
    <!-- https://mvnrepository.com/artifact/org.springframework.session/spring-session -->  
    <dependency>  
      <groupId>org.springframework.session</groupId>  
      <artifactId>spring-session</artifactId>  
      <version>1.2.2.RELEASE</version>  
    </dependency>  
    <!-- https://mvnrepository.com/artifact/org.springframework.data/spring-data-elasticsearch -->  
    <dependency>  
      <groupId>org.springframework.data</groupId>  
      <artifactId>spring-data-elasticsearch</artifactId>  
      <version>2.0.5.RELEASE</version>  
    </dependency>  
    <!-- hibernate -->  
    <!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->  
    <dependency>  
      <groupId>org.hibernate</groupId>  
      <artifactId>hibernate-core</artifactId>  
      <version>5.2.5.Final</version>  
    </dependency>  
    <!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-c3p0 -->  
    <dependency>  
      <groupId>org.hibernate</groupId>  
      <artifactId>hibernate-c3p0</artifactId>  
      <version>5.2.5.Final</version>  
    </dependency>  
    <!-- https://mvnrepository.com/artifact/ch.qos.logback/logback-classic -->  
    <dependency>  
      <groupId>ch.qos.logback</groupId>  
      <artifactId>logback-classic</artifactId>  
      <version>1.1.8</version>  
    </dependency>  
    <!-- servlet -->  
    <dependency>  
      <groupId>javax.servlet</groupId>  
      <artifactId>servlet-api</artifactId>  
      <version>2.5</version>  
    </dependency>  
    <dependency>  
      <groupId>javax.servlet</groupId>  
      <artifactId>jstl</artifactId>  
      <version>1.2</version>  
    </dependency>  
    <!-- https://mvnrepository.com/artifact/javax.inject/javax.inject -->  
    <dependency>  
      <groupId>javax.inject</groupId>  
      <artifactId>javax.inject</artifactId>  
      <version>1</version>  
    </dependency>  
    <!-- https://mvnrepository.com/artifact/com.h2database/h2 -->  
    <dependency>  
      <groupId>com.h2database</groupId>  
      <artifactId>h2</artifactId>  
      <version>1.4.193</version>  
    </dependency>  
    <!-- json -->  
    <dependency>  
      <groupId>net.sf.json-lib</groupId>  
      <artifactId>json-lib</artifactId>  
      <version>2.3</version>  
      <classifier>jdk15</classifier>  
    </dependency>  
  </dependencies>  
  <build>  
    <finalName>OnlyMyTest</finalName>  
  </build>  
</project>  

web.xml

<?xml version="1.0" encoding="UTF-8"?>  
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"  
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
        xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"  
        version="3.1">  
  <display-name>Archetype Created Web Application</display-name>  
  <listener>  
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>  
  </listener>  
  <context-param>  
    <param-name>contextConfigLocation</param-name>  
    <param-value>classpath:applicationContext.xml,classpath:daoContext.xml</param-value>  
  </context-param>  
  <servlet>  
    <servlet-name>mvc-dispatcher</servlet-name>  
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>  
    <init-param>  
      <param-name>contextConfigLocation</param-name>  
      <param-value>classpath:mvc-dispatcher-servlet.xml</param-value>  
    </init-param>  
    <load-on-startup>1</load-on-startup>  
  </servlet>  
  <servlet-mapping>  
    <servlet-name>mvc-dispatcher</servlet-name>  
    <url-pattern>/</url-pattern>  
  </servlet-mapping>  
</web-app>  

applicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>  
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
       xmlns="http://www.springframework.org/schema/beans"  
       xmlns:p="http://www.springframework.org/schema/p"  
       xmlns:c="http://www.springframework.org/schema/c"  
       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:context="http://www.springframework.org/schema/context"  
       xsi:schemaLocation="http://www.springframework.org/schema/beans  
       http://www.springframework.org/schema/beans/spring-beans-4.0.xsd  
       http://www.springframework.org/schema/tx  
       http://www.springframework.org/schema/tx/spring-tx-4.0.xsd  
       http://www.springframework.org/schema/aop  
       http://www.springframework.org/schema/aop/spring-aop-4.0.xsd  
       http://www.springframework.org/schema/task  
       http://www.springframework.org/schema/task/spring-task-3.1.xsd   
       http://www.springframework.org/schema/context   
       http://www.springframework.org/schema/context/spring-context.xsd">  
    <!-- 定义Service组件,并将DAO组件注入Service组件 -->  
    <bean id="myService" class="service.MyService"  
    />  
    <context:annotation-config />  
</beans>  

原文发布于微信公众号 - Java帮帮(javahelp)

原文发表时间:2016-12-30

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

相关文章

来自专栏增长技术

deploy to heroku

1121
来自专栏一个会写诗的程序员的博客

LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. Either remove Logba...

LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. Ei...

3165
来自专栏一个会写诗的程序员的博客

Kotlin Compiler Plugins : All-open , Kotlin-spring,No-arg,Kotlin-jpaCompiler Plugins

Kotlin has classes and their members final by default, which makes it inconvenie...

1922
来自专栏Laoqi's Linux运维专列

MHA快速搭建

2756
来自专栏康怀帅的专栏

CoreOS 配置工具 Ignition v2.2

This pre-release version of the specification is experimental and is subject to ...

3556
来自专栏一个会写诗的程序员的博客

$ spring init --list

1052
来自专栏Netkiller

Phalcon VS Spring 用法对照手册

Phalcon VS Spring 摘要 Phalcon VS Spring 用法对照表 ---- 目录 1. Install 1.1. Phalcon 1.2...

4106
来自专栏运维

CentOS 7.5安装部署Jewel版本Ceph集群

1、修改cpeh.conf文件 注意mon为奇数,如果为偶数,有一个不会安装,另外设置好public_network,并稍微增大mon之间时差允许范围(默认为0...

1043
来自专栏Netkiller

Spring Boot 快速开始

节选自 《Netkiller Java 手札》 11.2. Spring Boot 11.2.1. pom.xml <project xmlns="http...

3505
来自专栏一个会写诗的程序员的博客

Spring Fu is an incubator for new Spring features about Kotlin and functional bean registration.

Spring Fu is an incubator for new Spring features about Kotlin and functional be...

1414

扫码关注云+社区

领取腾讯云代金券