SSM框架的集成及登陸功能的實現

工程結構 maven+ssm+bootstrap實現簡單的增刪改查 :javascript


這裏寫圖片描述

 

pom文件:css

<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.summer</groupId> <artifactId>ssmdemo</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>war</packaging> <dependencies> <!-- springMVC --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>4.3.7.RELEASE</version> </dependency> <!-- spring jdbc --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> <version>4.3.7.RELEASE</version> </dependency> <!-- spring aop --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aspects</artifactId> <version>4.3.7.RELEASE</version> </dependency> <!-- mybatis --> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>3.4.2</version> </dependency> <!-- mybatis與spring整合 --> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis-spring</artifactId> <version>1.3.1</version> </dependency> <!-- 數據庫鏈接池 和驅動--> <dependency> <groupId>c3p0</groupId> <artifactId>c3p0</artifactId> <version>0.9.1.2</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.40</version> </dependency> <!-- jstl junit servlet-api --> <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <version>1.2</version> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.1.0</version> <scope>provided</scope> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> <scope>test</scope> </dependency> <!-- spring單元測試 --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> <version>4.3.7.RELEASE</version> <scope>test</scope> </dependency> <!-- 引入Mybatis分頁插件 --> <!-- 引入5.0版本在測試的時候會報錯 4.2版本也會報錯 4.2版本老是出現String沒法轉換爲某個對象的錯誤 --> <dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper</artifactId> <version>4.1.5</version> </dependency> </dependencies> </project>

jar包一覽 
這裏寫圖片描述
html

1:實體類:前端

package com.ssm.model; /** * 描述:用戶實體類 * @version */ public class User { //主鍵 private int id; //用戶名 private String username; //年齡 private String age; public User() { super(); } public User(int id, String username, String age) { super(); this.id = id; this.username = username; this.age = age; } 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 getAge() { return age; } public void setAge(String age) { this.age = age; } }
2:*建立DAO接口【在mybatis中 mapper就至關於dao】*
package com.ssm.mapper; import java.util.List; import com.ssm.model.User; /** * 描述:用戶mapper接口 * @version */ public interface UserMapper { void saveUser(User user); boolean updateUser(User user); boolean deleteUser(int id); User findUserById(int id); List<User> findAll(); }

 

*3:實現dao接口【mybatis中就是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"> <!-- namespace:必須與對應的接口全類名一致 UserMapper.java id :必須與對應接口的某個對應的方法名一致即必需要和UserMapper.java接口中的方法同名。 --> <mapper namespace="com.ssm.mapper.UserMapper"> <!-- 新增 --> <insert id="saveUser" parameterType="User" > insert into t_user(user_name,user_age) values (#{username},#{age}) </insert> <!-- 修改 --> <update id="updateUser" parameterType="User" > update t_user set user_name=#{username},user_age=#{age} where user_id=#{id} </update> <!-- 刪除 --> <delete id="deleteUser" parameterType="int"> delete from t_user where user_id=#{id} </delete> <!-- 根據id查找單個用戶 --> <select id="findUserById" parameterType="int" resultType="User"> select user_id id,user_name username,user_age age from t_user where user_id=#{id} </select> <!-- 查詢全部 --> <select id="findAll" resultType="User"> select user_id id,user_name userName,user_age age from t_user </select> </mapper>
4:spring配置文件
<?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:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.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/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd "> <!-- 註解掃描包 --> <context:component-scan base-package="com.summer" /> <!-- 加載jdbc.properties文件 --> <context:property-placeholder location="classpath:jdbc.properties"/> <!--第一步: 配置數據源 --> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"> <property name="jdbcUrl" value="${jdbc.url}"></property> <property name="driverClass" value="${jdbc.driver}"></property> <property name="user" value="${jdbc.username}"></property> <property name="password" value="${jdbc.password}"></property> </bean> <!-- 配置和mybatis的整合 --> <!--第二步: 建立sqlSessionFactory工廠 --> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource"></property> <!-- 指定Mybatis全局配置文件的位置 --> <property name="configLocation" value="classpath:sqlConfig.xml"></property> </bean> <!-- 配置mybatis的代理接口開發 * 接口類名和映射文件必須同名 * 接口類和映射文件必須在同一個目 錄下 * 接口的映射文件的namespace名稱必須是接口的全限定名 * 接口的方法名必須和映射的statement的id一致 --> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <!-- 掃描全部dao接口的實現,加入到ioc容器中 --> <property name="basePackage" value="com.ssm.mapper"></property> <property name="SqlSessionFactoryBeanName" value="sqlSessionFactory"></property> </bean> <!--第三步: 事物 --> <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource"></property> </bean> <!-- 配置攔截service --> <aop:config> <aop:pointcut expression="execution(* com.ssm.service..*(..))" id="txPoint"/> <aop:advisor advice-ref="txAdvice" pointcut-ref="txPoint"/> </aop:config> <!-- 配置事物加強,事物如何切入--> <tx:advice id="txAdvice" transaction-manager="txManager"> <tx:attributes> <!-- 全部方法都是事物方法 --> <tx:method name="*"/> <!-- 以get開始的全部方法 --> <tx:method name="get*" read-only="true"/> </tx:attributes> </tx:advice> </beans>

 

5:mybatis配置文件
<?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> <!-- 別名設置 --> <typeAliases> <package name="com.ssm.model" /> </typeAliases> <!-- mybatis分頁插件 --> <plugins> <plugin interceptor="com.github.pagehelper.PageHelper"></plugin> </plugins> </configuration>

6:log4j.properties ### set log levels ### log4j.rootLogger = INFO , console , debug , error ### console ### log4j.appender.console = org.apache.log4j.ConsoleAppender log4j.appender.console.Target = System.out log4j.appender.console.layout = org.apache.log4j.PatternLayout log4j.appender.console.layout.ConversionPattern = %-d{yyyy-MM-dd HH\:mm\:ss} [%p]-[%c] %m%n ### log file ### log4j.appender.debug = org.apache.log4j.DailyRollingFileAppender log4j.appender.debug.File = ../logs/springmvc-demo.log log4j.appender.debug.Append = true log4j.appender.debug.Threshold = INFO log4j.appender.debug.layout = org.apache.log4j.PatternLayout log4j.appender.debug.layout.ConversionPattern = %-d{yyyy-MM-dd HH\:mm\:ss} [%p]-[%c] %m%n ### exception ### log4j.appender.error = org.apache.log4j.DailyRollingFileAppender log4j.appender.error.File = ../logs/springmvc-demo_error.log log4j.appender.error.Append = true log4j.appender.error.Threshold = ERROR log4j.appender.error.layout = org.apache.log4j.PatternLayout log4j.appender.error.layout.ConversionPattern = %-d{yyyy-MM-dd HH\:mm\:ss} [%p]-[%c] %m%n ###\u9700\u8981\u58F0\u660E\uFF0C\u7136\u540E\u4E0B\u65B9\u624D\u53EF\u4EE5\u4F7Fdruid sql\u8F93\u51FA\uFF0C\u5426\u5219\u4F1A\u629B\u51FAlog4j.error.key not found log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.Target=System.out log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%d{ISO8601} %l %c%n%p: %m%n ### druid sql ### log4j.logger.druid.sql=warn,stdout log4j.logger.druid.sql.DataSource=warn,stdout log4j.logger.druid.sql.Connection=warn,stdout log4j.logger.druid.sql.Statement=warn,stdout log4j.logger.druid.sql.ResultSet=warn,stdout 
7:springmvc.xml springmvc的配置文件
<?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:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.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/context/spring-tx.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd "> <!-- 掃描註解包 --> <context:component-scan base-package="com.ssm"></context:component-scan> <!-- 配置sprigmvc視圖解析器:解析邏輯試圖 後臺返回邏輯試圖:index 視圖解析器解析出真正物理視圖:前綴+邏輯試圖+後綴====/WEB-INF/page/index.jsp--> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/page/"></property> <property name="suffix" value=".jsp"></property> </bean> <!--1: mvc:annotation-driven默認建立了 RequestMappingHandlerMapping和 RequestMappingHandlerAdapter對象 提供對JSon數據格式的支持--> <mvc:annotation-driven /> <!-- 2.配置靜態資源訪問 --> <mvc:default-servlet-handler/> </beans>

8:jdbc.properties jdbc.url = jdbc\:mysql\:///ssm jdbc.driver = com.mysql.jdbc.Driver jdbc.username= root jdbc.password= root
9: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>ssmdemo</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> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <!-- 配置SpringMVC核心控制器 --> <servlet> <servlet-name>dispatcherServlet</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:springmvc.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <!-- 攔截全部請求 --> <servlet-mapping> <servlet-name>dispatcherServlet</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> <!-- 字符編碼過濾器 --> <filter> <filter-name>CharacterEncodingFilter</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> </filter> <filter-mapping> <filter-name>CharacterEncodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </web-app>
10:創建service以及service實現【UserService.java】 package com.ssm.service; import java.util.List; import com.ssm.model.User; /** * 描述:用戶service * @version */ public interface UserService { void saveUser(User user); boolean updateUser(User user); boolean deleteUser(int id); User findUserById(int id); List<User> findAll(); }
service實現類
package com.ssm.service.impl; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.ssm.mapper.UserMapper; import com.ssm.model.User; import com.ssm.service.UserService; @Service /** * 描述:用戶service實現類 * @version */ public class UserServiceImpl implements UserService { /** * 注入UserMapper接口 */ @Autowired private UserMapper userMapper; /** * 新增用戶 */ @Override public void saveUser(User user) { userMapper.saveUser(user); } /** * 更新用戶 */ @Override public boolean updateUser(User user) { return userMapper.updateUser(user); } /** * 根據Id刪除用戶 */ @Override public boolean deleteUser(int id) { return userMapper.deleteUser(id); } /** * 根據id查找用戶 */ @Override public User findUserById(int id) { User user = userMapper.findUserById(id); return user; } /** * 查詢全部用戶 */ @Override public List<User> findAll() { List<User> allUser = userMapper.findAll(); return allUser; } }
 後端部分至此基本結束 ,下面就是前臺頁面11:創建controller package com.ssm.controller; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.ssm.model.User; import com.ssm.service.UserService; @Controller @RequestMapping("/user") /** * 描述:用戶controller * @version */ public class UserController { @Autowired private UserService userService; /** *跳轉到添加用戶界面 */ @RequestMapping("toAddUser") public String toAddUser(){ return "addUser"; } /** * 添加用戶並重定向 * @param model * @param user * @return */ @RequestMapping("addUser") public String addUser(Model model,User user){ if(user != null){ userService.saveUser(user); } return "redirect:/user/userInfo"; } /** * 修改用戶 * @param model * @param request * @param user * @return */ @RequestMapping("updateUser") public String UpdateUser(Model model,User user){ if(userService.updateUser(user)){ user = userService.findUserById(user.getId()); model.addAttribute("user", user); return "redirect:/user/userInfo"; } return "/error"; } /** * 查詢全部用戶 * @param request * @param model * @return */ @RequestMapping("getAllUser") public String getAllUser(Model model){ List<User> user = userService.findAll(); model.addAttribute("userList",user); return "allUser"; } /** * 查詢單個用戶 * @param id * @param request * @param model * @return */ @RequestMapping("/getUser") public String getUser(int id,Model model){ model.addAttribute("user", userService.findUserById(id)); return "editUser"; } /** * 根據id刪除用戶 * @param id * @param request * @param response */ @RequestMapping("/delUser") public String deleteUser(int id,Model model){ model.addAttribute("user", userService.deleteUser(id)); return "redirect:/user/userInfo"; } /** * 分頁查詢用戶信息 * @param pn 默認從第一頁開始 請求參數 * @param model * @return */ @RequestMapping("userInfo") public String getUsers(@RequestParam(value="pn",defaultValue="1")Integer pn,Model model){ //從第一條開始 每頁查詢五條數據 PageHelper.startPage(pn, 5); List<User> users = userService.findAll(); //將用戶信息放入PageInfo對象裏 PageInfo page = new PageInfo(users,5); model.addAttribute("pageInfo", page); return "allUser"; } }

因爲除了首頁 其餘頁面都是放在WEB-INF下 因此咱們經過首頁來跳轉一下
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <% pageContext.setAttribute("path", request.getContextPath()); %> <!DOCTYPE htm > <html> <head> <title>首頁</title> <style type="text/css"> a { text-decoration: none; color: #fff; font-size: 14px; } h3 { width: 180px; height: 38px; margin: 100px auto; text-align: center; line-height: 38px; background: #5BC0DE; border-radius: 4px; } </style> </head> <body> <h3> <a href="${path }/user/userInfo">進入用戶管理頁</a> </h3> </body> </html>

這裏寫圖片描述

點擊這裏能夠跳轉到用戶列表界面 
在頁面引入bootstrap須要的文件 他提供的按鈕樣式 列表樣式 分頁導航等很方便,省的咱們在去寫前端的東西
java

用戶列表界面
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <% pageContext.setAttribute("path", request.getContextPath()); %> <!DOCTYPE HTML> <html> <head> <title>用戶列表</title> <link href="${path}/static/bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet"> <script type="text/javascript" src="${path}/static/bootstrap-3.3.7-dist/js/jquery-1.10.1.min.js"></script> <script type="text/javascript" src="${path}/static/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script> </head> <body> <div class="container"> <!-- 標題 --> <div class="row"> <div class="col-md-12"> <h1>用戶管理</h1> </div> </div> <!-- 按鈕 --> <div class="row"> <div class="col-md-4 col-md-offset-8"> <a class="btn btn-primary" href="${path}/user/toAddUser">新增</a> </div> </div> <!-- 表格 --> <div class="row"> <div class="col-md-12"> <table class="table table-hover"> <tr> <th>id</th> <th>用戶名</th> <th>年齡</th> <th>操做</th> </tr> <c:forEach items="${pageInfo.list }" var="user"> <tr> <td>${user.id}</td> <td>${user.username }</td> <td>${user.age }</td> <!-- <td><a class="edit">編輯</a> <a class="delete">刪除</a></td> --> <td> <a type="button" href="${path}/user/getUser?id=${user.id}" class="btn btn-info btn-sm"> <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> 編輯</a> <a type="button" href="${path}/user/delUser?id=${user.id}" class="btn btn-danger btn-sm"> <span class="glyphicon glyphicon-trash" aria-hidden="true" ></span> 刪除</a> </td> </tr> </c:forEach> </table> </div> </div> <hr style="height:1px;border:none;border-top:1px solid #ccc;" /> <!-- 分頁導航欄 --> <!-- 分頁信息 --> <div class="row"> <!-- 分頁文字信息,其中分頁信息都封裝在pageInfo中 --> <div class="col-md-6"> 當前第:${pageInfo.pageNum}頁,總共:${pageInfo.pages}頁,總共:${pageInfo.total}條記錄 </div> <!-- 分頁條 --> <div class="col-md-6"> <nav aria-label="Page navigation"> <ul class="pagination"> <li><a href="${path}/user/userInfo?pn=1">首頁</a></li> <c:if test="${pageInfo.hasPreviousPage }"> <li> <a href="${path}/user/userInfo?pn=${pageInfo.pageNum-1}" aria-label="Previous"> <span aria-hidden="true">&laquo;</span> </a> </li> </c:if> <c:forEach items="${pageInfo.navigatepageNums }" var="page_Num"> <c:if test="${page_Num == pageInfo.pageNum }"> <li class="active"><a href="#">${ page_Num}</a></li> </c:if> <c:if test="${page_Num != pageInfo.pageNum }"> <li><a href="${path}/user/userInfo?pn=${ page_Num}">${ page_Num}</a></li> </c:if> </c:forEach> <c:if test="${pageInfo.hasNextPage }"> <li> <a href="${path}/user/userInfo?pn=${pageInfo.pageNum+1}" aria-label="Next"> <span aria-hidden="true">&raquo;</span> </a> </li> </c:if> <li><a href="${path}/user/userInfo?pn=${pageInfo.pages}">末頁</a></li> </ul> </nav> </div> </div> </div> </body> </html>

 

經過首頁 就跳到了這裏來 而後進行增刪改查 
在引入mybatis分頁插件的時候5.0 版本會出現找不到sqlSessionFactory的異常 4.2版本會報轉換異常 鬱悶 因此這裏 若是大家也遇到了一樣的問題 能夠注意一下 
這裏寫圖片描述
mysql

用戶添加界面
爲了省事 不必引入bootstrap了 
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/"; %> <html> <title>添加用戶</title> </head> <body> <h1>添加用戶</h1> <form action="" name="userForm"> 姓名:<input type="text" name="username"><br> 年齡:<input type="text" name="age"><br> <input type="button" value="添加" onclick="addUser()"> </form> <script type="text/javascript"> function addUser() { var form = document.forms[0]; form.action = "<%=basePath %>user/addUser"; form.method = "post"; form.submit(); } </script> </body> </html> 

 

這裏寫圖片描述

修改界面
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/"; %> <!DOCTYPE html> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <html> <head> <title>編輯用戶</title> <script type="text/javascript"> function updateUser() { var form = document.forms[0]; form.action = "<%=basePath %>user/updateUser"; form.method = "post"; form.submit(); } </script> </head> <body> <h1>添加用戶</h1> <form action="" name="userForm"> <input type="hidden" name="id" value="${user.id }" /> 姓名:<input type="text" name="username" value="${user.username }" /> 年齡:<input type="text" name="age" value="${user.age }" /> <input type="button" value="編輯" onclick="updateUser()" /> </form> </body> </html>

這裏寫圖片描述

固然 刪除點擊一下就直接刪除了,而後會回顯到用戶列表頁面jquery

最後就是數據庫的建表語句 很簡單了 我這裏就貼上來 萬一有小夥伴要照着我這個來一遍 能夠直接複製粘貼過去就行了git

DROP TABLE IF EXISTS `t_user`; CREATE TABLE `t_user` ( `user_id` int(11) NOT NULL AUTO_INCREMENT, `user_name` varchar(20) NOT NULL, `user_age` varchar(20) NOT NULL, PRIMARY KEY (`user_id`) ) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8; 

這裏寫圖片描述

個人maven本身另外設置了一下,有的時候maven工程會毛病多多,總是出現找不到jar包的問題 
找到c盤這裏來 
這裏寫圖片描述
github

在進去 
這裏寫圖片描述
web

<!-- 阿里雲中央倉庫--> 在setting.xml中我配置的是阿里雲的中央倉庫 跟着視頻來的 <mirrors> <mirror> <id>alimaven</id> <name>aliyun maven</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> <mirrorOf>central</mirrorOf> </mirror> </mirrors> <!-- 設置jdk編譯版本--> <profile> <id>jdk1.7</id> <activation> <activeByDefault>true</activeByDefault> <jdk>1.7</jdk> </activation> <properties> <maven.compiler.source>1.7</maven.compiler.source> <maven.compiler.target>1.7</maven.compiler.target> <maven.compiler.compilerVersion>1.7</maven.compiler.compilerVersion> </properties> </profile>
相關文章
相關標籤/搜索