javaee_SSH
这是javaee课程的第六个实验ssh sturts2+sping 3+hibernate
现予以记录整个过程,以防遗忘
1.
2.
3.
4.
5.输入mvnrepository.com进入->搜索spring—>点击spring core
6.
pom.xml里面的内容可以在上面的官网上面索取,我下面给出我我们老师给我们配的一个,我就直接使用了,一般是没什么问题,
有却什么,再到这个官网上面进行寻找
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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>testsshmaven</groupId>
<artifactId>testsshmaven</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<spring.version>4.3.14.RELEASE</spring.version>
<struts.version>2.5.16</struts.version>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/javax.servlet/servlet-api -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.eclipse.persistence/javax.persistence -->
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>javax.persistence</artifactId>
<version>2.2.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-core -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-beans -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-context -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-web -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-jdbc -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-orm -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.2.16.Final</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.struts/struts2-core -->
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>${struts.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.struts/struts2-spring-plugin -->
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-spring-plugin</artifactId>
<version>${struts.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.struts/struts2-convention-plugin -->
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-convention-plugin</artifactId>
<version>${struts.version}</version>
</dependency> <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>6.0.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-dbcp/commons-dbcp -->
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.4</version>
</dependency> </dependencies>
</project>
7.接下来,配置struts.xml,注意,放在main->resource
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.5//EN" "http://struts.apache.org/dtds/struts-2.5.dtd">
<!-- 注意:编程或运行时要联网 -->
<struts>
<constant name="struts.i18n.encoding" value="utf-8"/>
<constant name="struts.convention.action.packages" value="action"/>
<constant name="struts.enable.DynamicMethodInvocation" value="true" />
<!-- <global-allowed-methods>*</global-allowed-methods> -->
<!-- <package name="test" namespace="/" extends="struts-default">
<global-allowed-methods>*</global-allowed-methods>
</package> -->
</struts>
8.配置spring.xml 注意,放在main->resource
<?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:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd">
<!-- 引入properties -->
<context:property-placeholder location="classpath:database.properties"/>
<!-- 开启包扫描,并注册注解,扫描@Service,@Controller,@Repository,.... -->
<context:component-scan base-package="action,lib"/> <!-- 配置数据源 -->
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="${jdbc.driver}">
</property>
<property name="url" value="${jdbc.url}">
</property>
<property name="username" value="${jdbc.user}"></property>
<property name="password" value="${jdbc.password}"></property>
</bean> <!-- 配置hibernate sessionfactory -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
<prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
</props>
</property>
<property name="mappingResources">
<list>
<!-- <value>lib/Account.hbm.xml</value> -->
</list>
</property>
<!-- Scan entities automatically 自动扫描实体类Entity -->
<property name="packagesToScan" value="lib"/>
</bean> </beans>
9.注解映射实体和表:https://www.cnblogs.com/liuconglin/p/6096174.html
10.
javaee_SSH的更多相关文章
- oracle启用归档日志
一.开启归档 1.查看归档信息 SQL> archive log list Database log mode No Archive Mode Automatic archival Disabl ...
- java 与大数据学习较好的网站
C# C#中 Thread,Task,Async/Await,IAsyncResult 的那些事儿!https://www.cnblogs.com/doforfuture/p/6293926.html ...
随机推荐
- ajax请求json数据跨域问题(转)
一.后台代理技术 由服务器端向跨域下的网站发出请求,再将请求结果返回给前端,成功避免同源策略的限制. 具体操作如下: 1.在localhost:81/a.html中,向同源下的某个代理程序发出请求 $ ...
- FineReport8.0如何连接FineIndex取数分析
1. 描述 在3.7及之前版本,FineReport连接都是通过安装多维数据集插件,然后通过多维数据库的方式连接FineBI(3.4-3.6对应711,3.7对应8.0),从4.0版本开始,FineR ...
- Python+Selenium笔记(十一):配置selenium Grid
(一) 前言 Selenium Grid可以将测试分布在若干个物理或虚拟机器上,从而实现分布方式或并行方式执行测试. 这个链接是官方的相关说明. https://github.com/Selenium ...
- go语言开发环境、goland、IDE
1.下载: https://studygolang.com/dl 可以从这个网址下载,版本根据你的系统来: 64位系统,可以下载推荐版本: 我安装的是32位系统,下载的是下面这个: 如果你的是其他的系 ...
- LeetCode题解之Longest Palindromic Substring
1.题目描述 2.问题分析 计算每个字符所组成的字符串的回文子串. 3.代码 string longestPalindrome(string s) { ; ; bool is_odd = false ...
- Django开发笔记(一)
Django开发笔记(一) 标签(空格分隔): Django Python 1. 创建并运行Django项目 创建开发环境 安装Django pip install django==version 执 ...
- sql Server插不进数据,以及Id自增的教程及注意事项
参考于:https://jingyan.baidu.com/article/fec4bce244f902f2608d8b7a.html 使用SQL Server 2014 数据库做web的项目出现错误 ...
- 获取本机正在使用的ipv4地址(访问互联网的IP)
[转]原文地址:http://www.cnblogs.com/lijianda/p/6604651.html 1.一个电脑有多个网卡,有线的.无线的.还有vmare虚拟的两个网卡.2.就算只有一个网卡 ...
- rsync 数据同步
什么是Rsync? Rsync是一款开源的.快速的.多功能的.可实现全量及增量的本地货远程数据同步备份的优秀工具.适用于unix/linux/windows等多种操作系统平台. Rsync具有可使本地 ...
- VC Debug和Release区别
https://msdn.microsoft.com/en-us/library/xz7ttk5s.aspx Optimizing Your Code Visual Studio 2015 The ...