eclipse 新建 maven 项目 添加 spring hibernate 的配置文件 详情
主要配置文件
pom.xml 项目的maven 配置文件 管理项目所需 jar 依赖支持
web.xml 项目的总 配置文件 :添加 spring和hibernate 支持
applicationContext.xml hibernate的配置文件
sping-servlet.xml spring的配置文件
jdbc-properties 数据库连接属性 文件
------------------------------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>com.o2ole</groupId>
<artifactId>CheLL</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>CheLL</name>
<url>http://www.o2ole.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<finalName>CheLL</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<encoding>UTF8</encoding>
</configuration>
</plugin>
</plugins>
</build>
<organization>
<name>北京欧乐互动网络科技有限公司</name>
<url>http://www.o2ole.com</url>
</organization> <!-- 发布支持 -->
<distributionManagement>
<repository>
<id>releases</id>
<name>Internal Releases</name>
<url>http://192.168.0.254:8080/nexus/content/repositories/releases</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<name>Internal Snapshots</name>
<url>http://192.168.0.254:8080/nexus/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement> <dependencies>
<!-- junit的依赖 -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<!-- 日志的依赖 -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.0.2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.7</version>
</dependency>
<!-- web模块类库的依赖 -->
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
<!-- 持久化类库的依赖 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.25</version>
</dependency>
<!-- spring模块类库的依赖 -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>4.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>4.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>4.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.1.1.RELEASE</version>
</dependency>
<!-- hibernate的依赖 -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.3.6.Final</version>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.4</version>
</dependency>
<!-- jackson的依赖 -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.4.3</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.4.3</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.4.3</version>
</dependency>
<!-- sybot的依赖 -->
<dependency>
<groupId>org.sybot</groupId>
<artifactId>webbase</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
------------------------------pom.xml 结束----------------------------------------------
------------------------------web.xml 开始----------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
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>CheLL</display-name> <context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param> <!-- 增加字符集过滤器,解决中文乱码问题 -->
<filter>
<filter-name>CharacterFilter</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> <!-- 启动SPring窗口的监听器 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener> <!-- Spring MVC配置 -->
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping> <!-- 分页过滤器 -->
<filter>
<filter-name>PaginationFilter</filter-name>
<filter-class>org.sybot.web.easyui.PaginationFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>PaginationFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping> <!-- 应用过滤器 -->
<filter>
<filter-name>ApplicationContextFilter</filter-name>
<filter-class>org.sybot.web.filter.ApplicationContextFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>ApplicationContextFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping> <filter>
<filter-name>openSessionInViewerFilter</filter-name>
<filter-class>org.springframework.orm.hibernate4.support.OpenSessionInViewFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>openSessionInViewerFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
------------------------------web.xml 结束----------------------------------------------
------------------------------applicationContext.xml 开始----------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!-- 引用Spring的多个Schema格式定义文件 -->
<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: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-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/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"> <!-- 打开Spring的Annotation支持 -->
<context:annotation-config />
<!-- 设定Spring 去哪些包中找Annotation -->
<context:component-scan base-package="com.o2ole.chell" /> <!-- 导入Src目录下的jdbc.properties文件 -->
<context:property-placeholder location="classpath:jdbc.properties" />
<!-- 引入属性文件 - -> <context:property-placeholder location="/WEB-INF/application.properties"/ --> <!-- 定义数据源 -->
<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="initialSize" value="5" />
<!-- 当最小空闲时,当连接少于minIdle时会自动去申请一些连接 -->
<property name="minIdle" value="2" />
<property name="maxActive" value="100" />
<property name="maxIdle" value="20" />
<property name="maxWait" value="1000" />
</bean> <!-- 定义hibernate相关配置 -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<!-- 注入数据源 -->
<property name="dataSource" ref="dataSource" />
<!-- 设置Spring取那个包中查找相应的实体类 -->
<property name="packagesToScan">
<list>
<value>org.sybot.vm.domain</value>
</list>
</property> <property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
<prop key="hibernate.format_sql">true</prop>
</props>
</property>
</bean> <!-- 配置Spring的事务处理 -->
<!-- 创建事务管理器 -->
<bean id="txManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean> <tx:annotation-driven transaction-manager="txManager" />
</beans>
------------------------------applicationContext.xml 结束----------------------------------------------
------------------------------sping-servlet.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: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-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/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd"> <!-- 配置静态资源,直接映射到对应的文件夹 -->
<mvc:resources mapping="/res/**" location="/WEB-INF/resources/" /> <!-- 扫描类包,将标注Spring注解的类自动转化bean,同时完成Bean的注入 -->
<mvc:annotation-driven />
<context:component-scan base-package="com.o2ole.chell" /> <!-- 配置视图解析器,将ModelAndView及客串解析为具体的页面 -->
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/page/" />
<property name="suffix" value=".jsp" />
</bean> <bean
class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters">
<list>
<ref bean="mappingJacksonHttpMessageConverter" />
</list>
</property>
</bean>
<bean id="mappingJacksonHttpMessageConverter"
class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>text/html;charset=UTF-8</value>
</list>
</property>
</bean>
</beans>
------------------------------sping-servlet.xml 结束----------------------------------------------
------------------------------jdbc-properties 开始----------------------------------------------
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url = jdbc\:mysql\://192.168.0.200\:3308/chell_center
jdbc.username = yd
jdbc.password = 123456
------------------------------jdbc-properties 结束----------------------------------------------
eclipse 新建 maven 项目 添加 spring hibernate 的配置文件 详情的更多相关文章
- eclipse新建maven项目(2)
本篇博文是继续之前的博文eclipse新建maven项目(1),那篇博文不在随笔在文章中.首先按照之前那篇博文进行创建maven项目操作,一系列操作下来之后发现刷新项目后会报错: 别急哈,可以解决. ...
- eclipse新建maven项目:'Building' has encountered a problem. Errors occurred during the build.
二.eclipse 新建maven 项目报错(因为没有配置maven环境) 1.问题: ① 出现的问题1: Could not calculate build plan:Plugin org.apac ...
- eclipse新建maven项目报错Could not resolve arachetype org.apache.maven.archetypes:mmaven-archetype-quickstart:1.1 from any of the configured repositories
使用eclipse新建maven项目,按下图所示选择后,报错 报错截图 报错详细信息 Could not resolve archetype org.apache.maven.archetypes:m ...
- eclipse 新建 maven 项目 步骤(初级入门新手)
安装 maven(百度) 和在eclipse 中svn(上一篇) 修改 maven 本地仓库 eclipse 属性 maven--> installations-->添加新的 自定义安装的 ...
- eclipse新建maven项目,修改默认jdk版本
我们新建maven项目,默认jdk版本是1.5,我们可以修改成我们想要的版本,有两种方法 1每个项目修改,在pom.xml添加 <build> <plugins> <!- ...
- eclipse新建maven项目(1)
首先看一下eclipse版本,我用的是最新版Mars2. 下载地址自行搜索关键字:“eclipse官网”即可,注意下版本,32bit or 64bit. maven插件以及svn等相关插件安装设置问题 ...
- Maven使用笔记(二)Eclipse中maven项目添加依赖
1.在Eclipse中创建Eclipse项目后如何添加jar包? 点击pom.xml文件.我们可以看到下面有7个标签. 各个标签的含义如下: Overview:显示maven项目的一些基本信息Depe ...
- eclipse 新建 maven 项目 + 消除错误
安装eclips以及maven自行去了解,这里不讲解 一.新建一个 maven 项目. 二.下一步选择项目架构 三.填写相关信息 group id: 一般都是 com点 项目名 aftriact.id ...
- eclipse新建maven项目出错 pom.xml报错
问题: 1.新建项目后会提示一个这样的错 maven-compiler-plugin:3.1:compile(1 errors) maven-compiler-plugin:3.1:testCompi ...
随机推荐
- HTML DOM事件
HTML DOM事件 1.HTML事件包括: (1)当用户点击鼠标时: (2)当页面已加载时: (3)当图像已加载时: (4)当鼠标移动到元素上时: (5)当输入字段被改变时: (6)当提交HTML表 ...
- 判断List、Map、Set是否为空及效率比较
//如果object为null,则设置为defaultValue ObjectUtils.defaultIfNull(object, defaultValue); //判断集合是否为null Li ...
- PythonOCC 3D图形库学习—创建立方体模型
Open CASCADE(简称OCC)平台是是一个开源的C++类库,OCC主要用于开发二维和三维几何建模应用程序,包括通用的或专业的计算机辅助设计CAD系统.制造或分析领域的应用程序.仿真应用程序或图 ...
- ABAP Enhancement:第一部分
声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...
- [SAP ABAP开发技术总结]选择屏幕——PARAMETERS
声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...
- [SAP ABAP开发技术总结]动态语句、动态程序
声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...
- SQL Server小技巧【1】
1.SQL防止修改数据时引起多用户并发,当一条数据被一个用户锁定的时候其他用户将无法修改,除非将其释放. UPDATE TABLENAME WITH(ROWLOCK) SET 字段='Value' W ...
- Codeforces Round #237 (Div. 2) A
链接:http://codeforces.com/contest/404/problem/A A. Valera and X time limit per test 1 second memory l ...
- C# 线程(四):生产者和消费者
From : http://kb.cnblogs.com/page/42530/ 前面说过,每个线程都有自己的资源,但是代码区是共享的,即每个线程都可以执行相同的函数.这可能带来的问题就是几个线程同时 ...
- Java I/O 文件加锁,压缩
文件加锁: 文件加锁机制允许我们同步访问某个作为共享资源的文件. public class Test { public static void main(String[] args) throws I ...