(4)Maven快速入门_4在Spring+SpringMVC+MyBatis+Oracle+Maven框架整合运行在Tomcat8中
利用Maven 创建Spring+SpringMVC+MyBatis+Oracle 项目
分了三个项目 Dao (jar) Service (jar) Controller (web)
工程下载地址:https://pan.baidu.com/s/1Q9I6V9Mlw47Eua18N9do3Q 密码 1kbs
遇到的几个坑:
1、oracle 的数据库连接jar Maven库中不存在!!!
Missing artifact com.oracle:ojdbc6 :jar:11.2.0
需要手动下载ojdbc 然后编译安装到本地maven仓库 :Windows(7) 系统运行 cmd 打开 DOS 窗口,进入 Oracle JDBC 驱动包所在的目录,执行命令
mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2. -Dpackaging=jar -Dfile=ojdbc6.jar
参考解决此问题的文章地址:Missing artifact com.oracle:ojdbc14:jar:10.2.0.4.0 解决方案
如果还报 驱动找不到
Could not
load JDBC driver class [oracle.jdbc.OracleDriver]
则直接把 ojdbc6.jar 直接放到tomcat的lib目录下。
2、*mapper.xml 等配置文件通常情况下要放在 src/main/resources目录下(推荐)!!!
如果*mapper.xml 是放在 src/main/java 目录下 则有时会出现 找不到xml文件的的情况,
for property 'mapperLocations'; nested exception is java.lang.IllegalArgumentException: Could not resolve resource
出现上述错误的主要原因在于 maven 并不会自动将 src/main/java 中的 xml 等资源文佳复制到 target/classes 中去,
,需要在pom.xml中 添加如下信息
<build>
<resources>
<!-- 编译之后包含xml -->
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
<filtering>true</filtering>
</resource>
<!-- 编译之后包含xml -->
<resource>
<directory>src/main/resources</directory>
<includes>
<include>*.xml</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
</build>
参考解决此问题的文章地址:maven项目无法打包编辑mapper下的xml文件
以上是利用Spring4+SpringMvc+mybatis+maven+Oracle 分项目搭建框架过程中遇到的坑。
下面贴出搭建过程:
1、dao 项目创建:
在eclipse中 new --->other--->maven ---->maven project 如下图:
next 如下图
next ,普通Java项目 选择quickstart 标红一项;javaweb项目 选择 webapp标红一项。此处是普通java项目 选择第一项。
next之后填写 Group Id 、Artifact Id 、Version(默认即可) 这三个参数组成了 Maven中 定位一个jar的坐标。
finish创建的项目,目录结构如下:
src/main/java
src/test/java
src/main/resources
pom.xml
打开pom.xml 注释以下标注内容
上述四个文件作用 可参考 (3)Maven快速入门_3在Eclipse中创建Maven项目打包成jar
此处说明下: main 目录下创建 dao和 entity的 package 对应的存放*Mapper.xml的mappers 的package需要放在resources目录下(推荐) 。如果 mappers的package放在 main下 dao 和 entity同一目录下 ,则 需要注意解决一下上文提到的mapper.xml找不到错误的问题。
pom.xml 内容:
log4j 、ojdbc 、mybatis的 maven 插件jar包。注:ojdbc一定要安装到本地maven仓库,否则即使在 pom.xml中引入ojdbc maven依赖中也没有 ojdbc.jar
<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.inspur.smvc</groupId>
<artifactId>dao</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<!-- 注释
<name>dao</name>
<url>http://maven.apache.org</url>
--> <!-- <build> -->
<!-- <resources> -->
<!-- 编译之后包含xml -->
<!-- <resource> -->
<!-- <directory>src/main/java</directory> -->
<!-- <includes> -->
<!-- <include>**/*.xml</include> -->
<!-- </includes> -->
<!-- <filtering>true</filtering> -->
<!-- </resource> -->
<!-- 编译之后包含xml -->
<!-- <resource> -->
<!-- <directory>src/main/resources</directory> -->
<!-- <includes> -->
<!-- <include>*.xml</include> -->
<!-- </includes> -->
<!-- <filtering>true</filtering> -->
<!-- </resource> -->
<!-- </resources> -->
<!-- </build> --> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> <dependencies> <!-- https://mvnrepository.com/artifact/log4j/log4j -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency> <!-- https://mvnrepository.com/artifact/oracle/ojdbc -->
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0</version> </dependency> <!-- <dependency> -->
<!-- <groupId>commons-dbcp</groupId> -->
<!-- <artifactId>commons-dbcp</artifactId> -->
<!-- <version>1.2.2</version> -->
<!-- </dependency> --> <!-- mybatis -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.4.6</version>
</dependency>
<!-- junit4.12 -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
maven repository maven仓库中搜索需要的jar 如 搜索 mybatis 把红色框选的内容复制到 pom.xml即可
UserDao.java
package com.inspur.smvc.dao; import com.inspur.smvc.entity.User; public interface UserDao {
public User login(User user);
}
User.java
package com.inspur.smvc.entity; public class User { private int id; private String userName;
private String password; public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
} }
UserMapper.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.inspur.smvc.dao.UserDao">
<select id="login" parameterType="User" resultType="User">
select * from t_user where userName=#{userName} and password=#{password}
</select>
</mapper>
log4j.properties
log4j.rootLogger=DEBUG, Console #Console
log4j.appender.Console=org.apache.log4j.ConsoleAppender
log4j.appender.Console.layout=org.apache.log4j.PatternLayout
log4j.appender.Console.layout.ConversionPattern=%d [%t] %-5p [%c] - %m%n log4j.logger.java.sql.ResultSet=INFO
log4j.logger.org.apache=INFO
log4j.logger.java.sql.Connection=DEBUG
log4j.logger.java.sql.Statement=DEBUG
log4j.logger.java.sql.PreparedStatement=DEBUG
mybatis-config.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<!-- 别名 -->
<settings>
<setting name="logImpl" value="LOG4J"/>
</settings>
<typeAliases>
<package name="com.inspur.smvc.entity"/>
</typeAliases>
</configuration>
t_user表的sql语句
-- Create table
create table T_USER
(
id NUMBER,
username NVARCHAR2(100),
password NVARCHAR2(100)
)
右键点击 pom.xml ---- Run As---- maven install 在target和本地仓库中生成 jar target目录中,生成内容如下:
右键点击 pom.xml ---- Run As---- maven clean 在target和本地仓库中清理 已经生成 jar ,重新执行 maven install 可再次生成jar
2、创建 service 项目 与dao项目创建的方式相同 ,只贴代码
项目结构如下:
pom.xml文件内容:
spring4 的maven依赖包, spring4 与mybatis集成的的maven依赖包 。
注:依赖dao项目 需要添加 dao项目的 maven信息 , 可从dao项目 pom.xml的中复制 groupid artifactId version 信息。
<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.inspur.smvc</groupId>
<artifactId>service</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging> <!-- <name>service</name> -->
<!-- <url>http://maven.apache.org</url> --> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> <dependencies> <!-- 依赖 dao -->
<dependency>
<groupId>com.inspur.smvc</groupId>
<artifactId>dao</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency> <!-- https://mvnrepository.com/artifact/org.mybatis/mybatis-spring -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>1.3.2</version>
</dependency> <!-- spring start-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.1.7.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>4.1.7.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>4.1.7.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.1.7.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>4.1.7.RELEASE</version>
</dependency> <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.1.7.RELEASE</version>
</dependency> <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.1.7.RELEASE</version>
</dependency> <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>4.1.7.RELEASE</version>
</dependency> <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
<version>4.1.7.RELEASE</version>
</dependency> <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>4.1.7.RELEASE</version>
</dependency> <!-- spring end --> <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
UserServiceImpl.java
package com.inspur.smvc.service.impl; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import com.inspur.smvc.dao.UserDao;
import com.inspur.smvc.entity.User;
import com.inspur.smvc.service.UserService; @Service("userService")
public class UserServiceImpl implements UserService{
@Autowired
private UserDao userDao; public User login(User user){
return userDao.login(user);
} }
UserService.java
package com.inspur.smvc.service; import com.inspur.smvc.entity.User; public interface UserService {
public User login(User user);
}
applicationContext.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:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd"> <!-- 自动扫描 -->
<context:component-scan base-package="com.inspur.smvc.service" /> <!-- 配置数据源 -->
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/>
<property name="url" value="jdbc:oracle:thin:@10.110.2.88:1521:scossora"/>
<property name="username" value="costnew"/>
<property name="password" value="costnew"/>
</bean> <!-- 配置mybatis的sqlSessionFactory -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<!-- 自动扫描mappers.xml文件 -->
<property name="mapperLocations" value="classpath:com/inspur/smvc/mappers/*.xml"></property>
<!-- mybatis配置文件 -->
<property name="configLocation" value="classpath:mybatis-config.xml"></property>
</bean> <!-- DAO接口所在包名,Spring会自动查找其下的类 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.inspur.smvc.dao" />
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property>
</bean> <!-- (事务管理)transaction manager, use JtaTransactionManager for global tx -->
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean> <!-- 配置事务通知属性 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<!-- 定义事务传播属性 -->
<tx:attributes>
<tx:method name="insert*" propagation="REQUIRED" />
<tx:method name="update*" propagation="REQUIRED" />
<tx:method name="edit*" propagation="REQUIRED" />
<tx:method name="save*" propagation="REQUIRED" />
<tx:method name="add*" propagation="REQUIRED" />
<tx:method name="new*" propagation="REQUIRED" />
<tx:method name="set*" propagation="REQUIRED" />
<tx:method name="remove*" propagation="REQUIRED" />
<tx:method name="delete*" propagation="REQUIRED" />
<tx:method name="change*" propagation="REQUIRED" />
<tx:method name="check*" propagation="REQUIRED" />
<tx:method name="get*" propagation="REQUIRED" read-only="true" />
<tx:method name="find*" propagation="REQUIRED" read-only="true" />
<tx:method name="load*" propagation="REQUIRED" read-only="true" />
<tx:method name="*" propagation="REQUIRED" read-only="true" />
</tx:attributes>
</tx:advice> <!-- 配置事务切面 -->
<aop:config>
<aop:pointcut id="serviceOperation"
expression="execution(* com.inspur.smvc.service.*.*(..))" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="serviceOperation" />
</aop:config> </beans>
依然需要 点击 pom.xml 右键执行 Run As 执行 maven install 在target目录 和本地maven仓库生成 jar
3、controller 项目 (web)
此处需要创建maven版本的 web项目 :选择 -webapp
项目结构如下:
此处比maven普通的java项目需要多web项目结构的信息 都存放在src/main/webapp下
pom.xml文件:
jsp 、servlet 、jstl、Springmvc 的 maven插件支持 还需要引入 service项目 (service项目中已经引入dao了, 所以不需要单独引入dao)。
引入之后maven插件中就会有service和dao项目
<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.inspur.smvc</groupId>
<artifactId>controller</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version> <!-- <name>controller Maven Webapp</name> -->
<!-- <url>http://maven.apache.org</url> --> <dependencies> <!-- 引入service -->
<dependency>
<groupId>com.inspur.smvc</groupId>
<artifactId>service</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency> <!-- https://mvnrepository.com/artifact/javax.servlet.jsp.jstl/jstl -->
<dependency>
<groupId>javax.servlet.jsp.jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency> <!-- https://mvnrepository.com/artifact/javax.servlet.jsp/javax.servlet.jsp-api -->
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>javax.servlet.jsp-api</artifactId>
<version>2.3.1</version>
<scope>provided</scope>
</dependency> <!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
<scope>provided</scope>
</dependency> <!-- 添加Spring支持 -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.1.7.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>4.1.7.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>4.1.7.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.1.7.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>4.1.7.RELEASE</version>
</dependency> <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.1.7.RELEASE</version>
</dependency> <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.1.7.RELEASE</version>
</dependency> <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>controller</finalName>
</build>
</project>
spring-mvc.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:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd"> <!-- 使用注解的包,包括子集 -->
<context:component-scan base-package="com.inspur.smvc.controller" /> <!-- 视图解析器 -->
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/" />
<property name="suffix" value=".jsp"></property>
</bean> </beans>
UserController.java
package com.inspur.smvc.controller; import javax.servlet.http.HttpServletRequest; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import com.inspur.smvc.entity.User;
import com.inspur.smvc.service.UserService; @Controller
@RequestMapping("/user")
public class UserController {
@Autowired
private UserService userService; @RequestMapping("/login")
public String login(User user,HttpServletRequest request){
User resultU = userService.login(user);
if(null == resultU){
request.setAttribute("user", user);
request.setAttribute("errorMsg", "用户名或者密码错误!");
return "index";
}else{
request.getSession().setAttribute("currentUser", resultU);
return "redirect:/success.jsp";
}
} }
MANIFEST.MF
Manifest-Version: 1.0
Class-Path:
web.xml
<?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_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>MyBatisPro05</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list> <!-- Spring配置文件 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<!-- 编码过滤器 -->
<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<async-supported>true</async-supported>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- Spring监听器 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener> <!-- 添加对springmvc的支持 -->
<servlet>
<servlet-name>springMVC</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring-mvc.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
<async-supported>true</async-supported>
</servlet>
<servlet-mapping>
<servlet-name>springMVC</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
</web-app>
index.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<form action="${pageContext.request.contextPath }/user/login.do" method="post">
userName:<input type="text" name="userName" value="${user.userName }"/><br/>
password:<input type="password" name="password" value="${user.password }"><br/>
<input type="submit" value="login"/><font color="red">${errorMsg }</font>
</form>
</body>
</html>
success.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
欢迎:${currentUser.userName }
</body>
</html>
controller web项目直接右键项目名 --->Run As --->Maven install 创建到target 和本地maven仓库中。
右键选中项目 ---Run As --->Run on Server 发布到tomcat
输入错误的用户名或者密码 提示如下:
输入正确的用户名或者密码 提示如下:
至此 : Spring4+mybatis3+SpringMvc+Oracle11g+tomcat7+maven 版本的工程就创建完成了。
(4)Maven快速入门_4在Spring+SpringMVC+MyBatis+Oracle+Maven框架整合运行在Tomcat8中的更多相关文章
- SSM(Spring+SpringMVC+Mybatis)+Mysql 框架整合搭建流程以及其间注意事项
复习SSM框架,太久没用自己手动撘一个,发现自己还是有很多地方忘记了和没注意的事项... 首先,直接给出总流程: 零.引jar包 1.引包(或者写maven.pom) 一.数据库部分 设计数据库各表结 ...
- 搭建springboot的ssm(spring + springmvc + mybatis)的maven项目
最终项目目录结构 创建过程 1.创建开关SpringBootApplication 为了创建快速.我们使用idea自带的创建springboot来创建结构,当然创建普通的web项目也是可以的.(使用e ...
- spring ,springmvc,mybatis 最基本的整合,没有多余的jar包和依赖 2018.9.29日
最基本的ssm框架整合 本案例采用2018商业版intellij idea 编辑器 maven项目管理工具 tomcat8.5 接着上一篇使用springmvc最基本配置开始 https: ...
- SSM框架整合(Spring+SpringMVC+MyBatis+Oracle)
1.开发环境搭建以及创建Maven Web项目 参看之前的博文[确保maven web项目不报错]:http://www.cnblogs.com/cainiaomahua/p/6306476.html ...
- spring+springmvc+mybatis+oracle+atomikos+jta实现多数据源事务管理
---恢复内容开始--- 在做项目过程中,遇到了需要一个项目中访问两个数据库的情况,发现使用常规的spring管理事务,导致事务不能正常回滚,因此,采用了jta+atomikos的分布式数据源方式 ...
- Springmvc+mybatis+restful+bootstrap框架整合
框架整合: Springmvc + Mybatis + Shiro(权限) + REST(服务) + WebService(服务) + JMS(消息) + Lucene(搜搜引擎) + Quartz( ...
- 【企业级框架整合】Springmvc+mybatis+restful+bootstrap框架整合
1. 使用阿里巴巴Druid连接池(高效.功能强大.可扩展性好的数据库连接池.监控数据库访问性能.支持Common-Logging.Log4j和JdkLog,监控数据库访问)2. 提供高并发JMS消息 ...
- spring+springMvc+struts的SSH框架整合
1.建立一个web项目 2.导入SSH框架所需jar包 3.配置web.xml文件 <?xml version="1.0" encoding="UTF-8" ...
- 基于Spring+SpringMVC+Mybatis的Web系统搭建
系统搭建的配置大同小异,本文在前人的基础上做了些许的改动,重写数据库,增加依据权限的动态菜单的实现,也增加了后台返回json格式数据的配置,详细参见完整源码. 主要的后端架构:Spring+Sprin ...
随机推荐
- 干掉safedog命令
sc delete safedogguardcenter shutdown -r -t 00 两条命令搞定
- Consider defining a bean named 'entityManagerFactory' in your configuration解决办法
错误信息: *************************** APPLICATION FAILED TO START *************************** Descriptio ...
- C语言复习4_while循环
1.while循环 循环三要素: 1).循环变量的初值 2).循环变量的判断 3).循环变量的更新 #include <stdio.h> #include <stdlib.h> ...
- qt5.4解决输出中文乱码问题
需要在字符串前添加 QString::fromUtf8 例: b2 = new QPushButton(this); b2->setText(QString::fromUtf8("变化 ...
- python 中间件
中间件一.什么是中间件 中间件是一个用来处理Django的请求和响应的框架级别的钩子.它是一个轻量.低级别的插件系统,用于在全局范围内改变Django 的输入和输出.每个中间件组件都负责做一些特定的功 ...
- filter 过滤器 禁止浏览器缓存
public class BrowserNoCacheFilter implements Filter { public void init(FilterConfig filterconfig) th ...
- 解决微信小程序video属性controls失效问题
<view class="VideoBox"> <video class='myVideo' id="myVideo01" src=" ...
- idea之debug
[转载]原文地址:https://www.cnblogs.com/nihaorz/p/7613967.html 在Intellij IDEA中使用Debug Debug用来追踪代码的运行流程,通常在程 ...
- [Swift]LeetCode831. 隐藏个人信息 | Masking Personal Information
We are given a personal information string S, which may represent either an email address or a phone ...
- [Reversing.kr] Easy Crack Writeup
题目:http://reversing.kr/ Easy Crack IDA打开.分析可知Sub_401080是关键函数.F5后. 当满足 则跳转成功.拼接后得到flag flag: Ea5yR3ve ...