小言_互联网的博客

实例!使用Idea创建SSM框架的Maven项目

354人阅读  评论(0)

大家好,我是雄雄,欢迎关注微信公众号【雄雄的小课堂】。

前言

书接前文,昨天带着大家下载且配置了maven,以及在idea中创建maven项目,今天,我们就结合ssm框架,在idea中实现一个增删改查案例。

昨天的文章:手把手教你搭建Maven项目

01

配置pom文件

通常,我们需要使用ssm框架的时候,需要加载一系列的jar包,在未使用maven的时候,我们则采用的是将所需jar包统统复制到项目的lib目录中,现在我们不必那样做了,只需要简单的在pom文件中配置即可。

那么,怎么配置呢?

我们以mysql的驱动jar为例(其他jar包配置方式一样,可执行按此配置),mysql的驱动jar包我采用的是:mysql-connector-java-8.0.23,配置方式如下:

1)maven官网为我们提供了jar包在pom文件中的配置方式,打开官网:https://search.maven.org/,我们在输入框中输入需要配置的jar包名,如下:

可以在左边框中的下拉列表里选择版本,在右边的Apache Maven下面,复制所有代码。

复制到项目中pom文件的这里:

如果你不知道ssm需要哪些jar包,可以去百度搜索,pom中配置方式是一样的,在这就不一一列举了,下面是整个pom.xml文件的代码:


   
  1. <?xml version= "1.0" encoding= "UTF-8"?>
  2. <project xmlns= "http://maven.apache.org/POM/4.0.0" xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance"
  3.   xsi:schemaLocation= "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  4.   <modelVersion> 4.0 .0</modelVersion>
  5.   <groupId>com.xiongxiong</groupId>
  6.   <artifactId>BookManageSys</artifactId>
  7.   <version> 1.0-SNAPSHOT</version>
  8.   <packaging>war</packaging>
  9.   <name>BookManageSys Maven Webapp</name>
  10.   <!-- FIXME change it to the project 's website -->
  11.   <url>http://www.example.com</url>
  12.   <properties>
  13.     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  14.     <maven.compiler.source>1.7</maven.compiler.source>
  15.     <maven.compiler.target>1.7</maven.compiler.target>
  16.   </properties>
  17.   <dependencies>
  18.     <!--配置jar包-->
  19.     <dependency>
  20.       <groupId>junit</groupId>
  21.       <artifactId>junit</artifactId>
  22.       <version>4.11</version>
  23.       <scope>test</scope>
  24.     </dependency>
  25.     <dependency>
  26.       <groupId>mysql</groupId>
  27.       <artifactId>mysql-connector-java</artifactId>
  28.       <version>8.0.23</version>
  29.     </dependency>
  30.     <!--spring的jar包=-->
  31.     <!--springmvc的jar包-->
  32.     <dependency>
  33.       <groupId>javaee</groupId>
  34.       <artifactId>javaee-api</artifactId>
  35.       <version>5</version>
  36.     </dependency>
  37.     <dependency>
  38.       <groupId>org.springframework</groupId>
  39.       <artifactId>spring-core</artifactId>
  40.       <version>4.2.5.RELEASE</version>
  41.     </dependency>
  42.     <dependency>
  43.       <groupId>org.springframework</groupId>
  44.       <artifactId>spring-beans</artifactId>
  45.       <version>4.2.2.RELEASE</version>
  46.     </dependency>
  47.     <dependency>
  48.       <groupId>org.springframework</groupId>
  49.       <artifactId>spring-context</artifactId>
  50.       <version>4.2.2.RELEASE</version>
  51.     </dependency>
  52.     <dependency>
  53.       <groupId>org.springframework</groupId>
  54.       <artifactId>spring-tx</artifactId>
  55.       <version>4.1.9.RELEASE</version>
  56.     </dependency>
  57.     <dependency>
  58.       <groupId>org.springframework</groupId>
  59.       <artifactId>spring-aspects</artifactId>
  60.       <version>4.2.1.RELEASE</version>
  61.     </dependency>
  62.     <dependency>
  63.       <groupId>org.springframework</groupId>
  64.       <artifactId>spring-context-support</artifactId>
  65.       <version>4.1.9.RELEASE</version>
  66.     </dependency>
  67.     <dependency>
  68.       <groupId>org.springframework</groupId>
  69.       <artifactId>spring-jdbc</artifactId>
  70.       <version>4.2.3.release</version>
  71.     </dependency>
  72.     <dependency>
  73.       <groupId>org.springframework</groupId>
  74.       <artifactId>spring-test</artifactId>
  75.       <version>4.1.9.RELEASE</version>
  76.     </dependency>
  77.     <dependency>
  78.       <groupId>org.springframework</groupId>
  79.       <artifactId>spring-web</artifactId>
  80.       <version>4.2.3.RELEASE</version>
  81.     </dependency>
  82.     <dependency>
  83.       <groupId>org.springframework</groupId>
  84.       <artifactId>spring-webmvc</artifactId>
  85.       <version>4.1.9.RELEASE</version>
  86.     </dependency>
  87.     <dependency>
  88.       <groupId>org.mybatis</groupId>
  89.       <artifactId>mybatis</artifactId>
  90.       <version>3.2.2</version>
  91.     </dependency>
  92.     <dependency>
  93.       <groupId>org.mybatis</groupId>
  94.       <artifactId>mybatis-spring</artifactId>
  95.       <version>1.3.0</version>
  96.     </dependency>
  97.     <dependency>
  98.       <groupId>org.javassist</groupId>
  99.       <artifactId>javassist</artifactId>
  100.       <version>3.17.1-GA</version>
  101.     </dependency>
  102.     <dependency>
  103.       <groupId>cglib</groupId>
  104.       <artifactId>cglib</artifactId>
  105.       <version>2.2.2</version>
  106.     </dependency>
  107.     <dependency>
  108.       <groupId>c3p0</groupId>
  109.       <artifactId>c3p0</artifactId>
  110.       <version>0.9.1.2</version>
  111.     </dependency>
  112.     <!--加载jstl的包-->
  113.     <dependency>
  114.       <groupId>jstl</groupId>
  115.       <artifactId>jstl</artifactId>
  116.       <version>1.2</version>
  117.     </dependency>
  118.   </dependencies>
  119.   <build>
  120.     <finalName>BookManageSys</finalName>
  121.     <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
  122.       <plugins>
  123.         <plugin>
  124.           <artifactId>maven-clean-plugin</artifactId>
  125.           <version>3.1.0</version>
  126.         </plugin>
  127.         <!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging -->
  128.         <plugin>
  129.           <artifactId>maven-resources-plugin</artifactId>
  130.           <version>3.0.2</version>
  131.         </plugin>
  132.         <plugin>
  133.           <artifactId>maven-compiler-plugin</artifactId>
  134.           <version>3.8.0</version>
  135.         </plugin>
  136.         <plugin>
  137.           <artifactId>maven-surefire-plugin</artifactId>
  138.           <version>2.22.1</version>
  139.         </plugin>
  140.         <plugin>
  141.           <artifactId>maven-war-plugin</artifactId>
  142.           <version>3.2.2</version>
  143.         </plugin>
  144.         <plugin>
  145.           <artifactId>maven-install-plugin</artifactId>
  146.           <version>2.5.2</version>
  147.         </plugin>
  148.         <plugin>
  149.           <artifactId>maven-deploy-plugin</artifactId>
  150.           <version>2.8.2</version>
  151.         </plugin>
  152.       </plugins>
  153.     </pluginManagement>
  154.   </build>
  155. </project>

这是最后导入的jar包:

02

在main目录中创建resources资源文件夹

该资源文件夹用来存放ssm的配置文件,applicationContext.xml,springmvc-servlet.xml,mybatis-config.xml

各配置文件代码如下:

applicationContext.xml文件


   
  1. <?xml version= "1.0" encoding= "UTF-8"?>
  2. <beans
  3.         xmlns= "http://www.springframework.org/schema/beans"
  4.         xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance"
  5.         xmlns:mvc= "http://www.springframework.org/schema/mvc"
  6.         xmlns:context= "http://www.springframework.org/schema/context"
  7.         xsi:schemaLocation= "
  8.   http://www.springframework.org/schema/beans
  9.   http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
  10.   http://www.springframework.org/schema/mvc
  11.   http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
  12.   http://www.springframework.org/schema/context
  13.   http://www.springframework.org/schema/context/spring-context-3.1.xsd
  14.   ">
  15.     <!-- 配置数据源-->
  16.     <bean id= "dataSource" class= "org.springframework.jdbc.datasource.DriverManagerDataSource">
  17.         <property name= "driverClassName" value= "com.mysql.jdbc.Driver"></property>
  18.         <property name= "url" value= "jdbc:mysql://localhost:3306/schooldb"></property>
  19.         <property name= "username" value= "root"></property>
  20.         <property name= "password" value= "root"></property>
  21.     </bean>
  22.     <!--sqlSessionFactory -->
  23.     <bean id= "sqlSessionFactory" class= "org.mybatis.spring.SqlSessionFactoryBean">
  24.         <property name= "dataSource" ref= "dataSource"></property>
  25.         <property name= "configLocation" value= "classpath:mybatis-config.xml"></property>
  26.         <property name= "mapperLocations">
  27.             <list>
  28.                 <value>classpath:com/dao /*.xml</value>
  29.             </list>
  30.         </property>
  31.     </bean>
  32.     <!-- 配置自动映射器 -->
  33.     <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
  34.         <property name="basePackage" value="com.dao"></property>
  35.     </bean>
  36.     <!-- 扫描所有注解信息 -->
  37.     <context:component-scan base-package="com.dao,com.service,com.web"/>
  38.     <mvc:annotation-driven/>
  39. </beans>

springmvc-servlet.xml文件


   
  1. <?xml version= "1.0" encoding= "UTF-8"?>
  2. <beans
  3.         xmlns= "http://www.springframework.org/schema/beans"
  4.         xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance"
  5.         xmlns:p= "http://www.springframework.org/schema/p"
  6.         xmlns:aop= "http://www.springframework.org/schema/aop"
  7.         xmlns:mvc= "http://www.springframework.org/schema/mvc"
  8.         xmlns:context= "http://www.springframework.org/schema/context"
  9.         xsi:schemaLocation= "
  10.   http://www.springframework.org/schema/beans
  11.   http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
  12.   http://www.springframework.org/schema/p
  13.   http://www.springframework.org/schema/p/spring-p-3.1.xsd
  14.   http://www.springframework.org/schema/aop
  15.   http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
  16.   http://www.springframework.org/schema/mvc
  17.   http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
  18.   http://www.springframework.org/schema/context
  19.   http://www.springframework.org/schema/context/spring-context-3.1.xsd
  20.   ">
  21.     <!-- 扫描注解 -->
  22.     <context:component-scan base- package= "com.web,com.dao,com.service"/>
  23.     <mvc:annotation-driven/>
  24.     <!--扫描静态资源文件-->
  25.     <mvc: default-servlet-handler/>
  26.     <!-- 配置前缀和后缀 -->
  27.     <bean class= "org.springframework.web.servlet.view.InternalResourceViewResolver">
  28.         <property name= "prefix" value= "/"></property>
  29.         <property name= "suffix" value= ".jsp"></property>
  30.     </bean>
  31. </beans>

mybatis-config.xml文件


   
  1. <?xml version= "1.0" encoding= "UTF-8" ?>
  2. <!DOCTYPE configuration
  3.         PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
  4.          "http://mybatis.org/dtd/mybatis-3-config.dtd">
  5. <configuration>
  6.     <settings>
  7.         <!-- 打印sql语句 -->
  8.         <setting name= "logImpl" value= "STDOUT_LOGGING"/>
  9.     </settings>
  10.     <!-- 起别名 -->
  11.     <typeAliases>
  12.         < package name= "com.entity"/>
  13.     </typeAliases>
  14. </configuration>

03

配置web.xml文件

web.xml文件所在的路径:src/main/webapp/WEB/INF/wen.xml

代码如下:


   
  1. <!DOCTYPE web-app PUBLIC
  2.   "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
  3.   "http://java.sun.com/dtd/web-app_2_3.dtd" >
  4. <web-app  xmlns= "http://xmlns.jcp.org/xml/ns/javaee"
  5.           xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance"
  6.           xsi:schemaLocation= "http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
  7.           version= "4.0">
  8.   <display-name>Archetype Created Web Application</display-name>
  9.   <welcome-file-list>
  10.     <welcome-file>/</welcome-file>
  11.   </welcome-file-list>
  12.   <!-- springmvc的配置 -->
  13.   <servlet>
  14.     <servlet-name>springmvc</servlet-name>
  15.     <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  16.     <init-param>
  17.       <param-name>contextConfigLocation</param-name>
  18.       <param-value>classpath:springmvc-servlet.xml</param-value>
  19.     </init-param>
  20.     <load-on-startup> 1</load-on-startup>
  21.   </servlet>
  22.   <servlet-mapping>
  23.     <servlet-name>springmvc</servlet-name>
  24.     <url-pattern>/</url-pattern>
  25.   </servlet-mapping>
  26.   <!-- spring -->
  27.   <context-param>
  28.     <param-name>contextConfigLocation</param-name>
  29.     <param-value>classpath:applicationContext.xml</param-value>
  30.   </context-param>
  31.   <!-- 监听配置 -->
  32.   <listener>
  33.     <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  34.   </listener>
  35.   <!-- 解决springmvc传递值乱码问题 -->
  36.   <filter>
  37.     <filter-name>encodingFilter</filter-name>
  38.     <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
  39.     <init-param>
  40.       <param-name>encoding</param-name>
  41.       <param-value>utf -8</param-value>
  42.     </init-param>
  43.     <init-param>
  44.       <param-name>forceEncoding</param-name>
  45.       <param-value> true</param-value>
  46.     </init-param>
  47.   </filter>
  48.   <filter-mapping>
  49.     <filter-name>encodingFilter</filter-name>
  50.     <url-pattern> /*</url-pattern>
  51.   </filter-mapping>
  52. </web-app>

04

创建src资源资源文件夹

在main文件夹中创建资源文件夹src,且在里面创建实体层、Dao层、Service层和web层。

下面我们来在src中创建包com(包名随便起),在com中分别创建entity、dao、service以及web包(Package),分别在各个包中创建对应的类,其目录结构如下:

下面是各个类的代码:

BookManage.java:


   
  1. package com.entity;
  2. import org.springframework.format.annotation.DateTimeFormat;
  3. import java.util.Date;
  4. public class BookManage {
  5.     private  int bid;
  6.     private String bname;
  7.     private String bauthor;
  8.     @DateTimeFormat(pattern = "yyyy-MM-dd")
  9.     private Date btime;
  10.     private  int btype;
  11.     public  int getBid() {
  12.          return bid;
  13.     }
  14.     public void setBid( int bid) {
  15.         this.bid = bid;
  16.     }
  17.     public String getBname() {
  18.          return bname;
  19.     }
  20.     public void setBname(String bname) {
  21.         this.bname = bname;
  22.     }
  23.     public String getBauthor() {
  24.          return bauthor;
  25.     }
  26.     public void setBauthor(String bauthor) {
  27.         this.bauthor = bauthor;
  28.     }
  29.     public Date getBtime() {
  30.          return btime;
  31.     }
  32.     public void setBtime(Date btime) {
  33.         this.btime = btime;
  34.     }
  35.     public  int getBtype() {
  36.          return btype;
  37.     }
  38.     public void setBtype( int btype) {
  39.         this.btype = btype;
  40.     }
  41. }

BookManageMapper.java


   
  1. package com.dao;
  2. import com.entity.BookManage;
  3. import java.util.List;
  4. public  interface BookManageMapper {
  5.      //查询全部
  6.     List<BookManage> findBookAll();
  7.      //添加
  8.      int addBook(BookManage bookManage);
  9.      //删除
  10.      int delBook( int bid);
  11. }

BookManageMapper.xml


   
  1. <?xml version= "1.0" encoding= "UTF-8" ?>
  2. <!DOCTYPE mapper
  3.         PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4.          "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace= "com.dao.BookManageMapper">
  6.     <!-- 查询全部 -->
  7.     < select id= "findBookAll" resultType= "BookManage">
  8.          select * from BookManage;
  9.     </ select>
  10.     <!-- 添加 -->
  11.     <insert id= "addBook" parameterType= "BookManage">
  12.         insert into bookmanage (bname,bauthor,btime,btype)
  13.         value(#{bname},#{bauthor},#{btime},#{btype});
  14.     </insert>
  15.     <!-- 删除 -->
  16.     < delete id= "delBook" parameterType= "int">
  17.          delete from BookManage where bid = #{bid};
  18.     </ delete>
  19. </mapper>

IBookManageService.java


   
  1. package com.service;
  2. import com.entity.BookManage;
  3. import java.util.List;
  4. public  interface IBookManageService {
  5.      //查询全部
  6.     List<BookManage> findBookAll();
  7.      //添加
  8.      int addBook(BookManage bookManage);
  9.      //删除
  10.      int delBook( int bid);
  11. }

BookManageServiceImpl.java


   
  1. package com.service.impl;
  2. import com.dao.BookManageMapper;
  3. import com.entity.BookManage;
  4. import com.service.IBookManageService;
  5. import org.springframework.beans.factory.annotation.Autowired;
  6. import org.springframework.stereotype.Service;
  7. import java.util.List;
  8. @Service( "bookManageService")
  9. public class BookManageServiceImpl implements IBookManageService {
  10.     @Autowired
  11.     private BookManageMapper bookManageMapper;
  12.     @Override
  13.     public List<BookManage> findBookAll() {
  14.          return bookManageMapper.findBookAll();
  15.     }
  16.     @Override
  17.     public  int addBook(BookManage bookManage) {
  18.          return bookManageMapper.addBook(bookManage);
  19.     }
  20.     @Override
  21.     public  int delBook( int bid) {
  22.          return bookManageMapper.delBook(bid);
  23.     }
  24.     public BookManageMapper getBookManageMapper() {
  25.          return bookManageMapper;
  26.     }
  27.     public void setBookManageMapper(BookManageMapper bookManageMapper) {
  28.         this.bookManageMapper = bookManageMapper;
  29.     }
  30. }

IndexController.java


   
  1. package com.web;
  2. import com.entity.BookManage;
  3. import com.service.IBookManageService;
  4. import org.springframework.beans.factory.annotation.Autowired;
  5. import org.springframework.stereotype.Controller;
  6. import org.springframework.ui.Model;
  7. import org.springframework.web.bind.annotation.RequestMapping;
  8. import java.util.List;
  9. @Controller
  10. @RequestMapping( "/")
  11. public class IndexController {
  12.      //创建Service的对象
  13.     @Autowired
  14.     private IBookManageService bookManageService;
  15.      //默认进入首页
  16.     @RequestMapping( "/")
  17.     public String index(Model model){
  18.         List<BookManage> bookManageList =
  19.                 bookManageService.findBookAll();
  20.         model.addAttribute( "bookManageList",bookManageList);
  21.          return  "index";
  22.     }
  23.      //删除
  24.     @RequestMapping( "delBook")
  25.     public String delBook(Model model, int bid){
  26.         bookManageService.delBook(bid);
  27.         index(model);
  28.          return  "index";
  29.     }
  30.      //添加
  31.     @RequestMapping( "addBook")
  32.     public String addBook(BookManage bookManage,Model model){
  33.         bookManageService.addBook(bookManage);
  34.         index(model);
  35.          return  "index";
  36.     }
  37.     public IBookManageService getBookManageService() {
  38.          return bookManageService;
  39.     }
  40.     public void setBookManageService(IBookManageService bookManageService) {
  41.         this.bookManageService = bookManageService;
  42.     }
  43. }

05

引入jQuery环境

将jquery的环境拷贝到项目中的webapp下:

06

首页

修改index.jsp,使其实现进入页面即查询数据库中所有数据功能,代码如下:


   
  1. <%--
  2.   Created by IntelliJ IDEA.
  3.   User:  24519
  4.   Date:  2021/ 1/ 20
  5.   Time:  10: 38
  6.   To change this template use File | Settings | File Templates.
  7. --%>  
  8. <%@ page isELIgnored= "false"%>
  9. <%@ page contentType= "text/html;charset=UTF-8" language= "java" %>
  10. <%@taglib prefix= "c" uri= "http://java.sun.com/jsp/jstl/core" %>
  11. <%@taglib prefix= "f" uri= "http://java.sun.com/jsp/jstl/fmt" %>
  12. <html>
  13.   <head>
  14.     <title>首页</title>
  15.   </head>
  16.   <body>
  17.     <h1>图书信息</h1>
  18.   <table border= "1">
  19.     <tr>
  20.       <td>图书名称</td>
  21.       <td>图书作者</td>
  22.       <td>购买时间</td>
  23.       <td>图书分类</td>
  24.       <td>操作</td>
  25.     </tr>
  26.     <c:forEach items= "${bookManageList}"  var= "book">
  27.       <tr>
  28.         <td>${book.bname}</td>
  29.         <td>${book.bauthor}</td>
  30.         <td>
  31.             <f:formatDate value= "${book.btime}" pattern= "yyyy-MM-dd"></f:formatDate>
  32.             </td>
  33.         <td>
  34.             <c: if test= "${book.btype==1}">
  35.               计算机/软件
  36.             </c: if>
  37.           <c: if test= "${book.btype==2}">
  38.             小说/文摘
  39.           </c: if>
  40.           <c: if test= "${book.btype==3}">
  41.             杂项
  42.           </c: if>
  43.         </td>
  44.         <td><a href= "delBook?bid=${book.bid}">删除</a></td>
  45.       </tr>
  46.     </c:forEach>
  47.   </table>
  48.   <a href= "addBook.jsp" style= "color:red">新增图书信息</a>
  49.   <script src= "js/jquery-1.12.4.js"  type= "text/javascript"></script>
  50.   <script  type= "text/javascript">
  51.     $(function(){
  52.         $( "tr:even").css( "background", "green");
  53.         $( "tr:first").css( "background", "blue");
  54.     });
  55.   </script>
  56.   </body>
  57. </html>

07

添加图书的页面

创建添加数据的页面addBook.jsp,代码如下:

注意,addBook.jsp和index.jsp都需要放在webapp目录下。

08

配置tomcat

配置tomcat


测试发现,正常运行。

最后附数据库脚本代码:


   
  1. /*
  2. SQLyog Professional v12.08 (32 bit)
  3. MySQL - 5.5.27 : Database - schooldb
  4. *********************************************************************
  5. */
  6. /*!40101 SET NAMES utf8 */;
  7. /*!40101 SET SQL_MODE=''*/;
  8. /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
  9. /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
  10. /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
  11. /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
  12. CREATE DATABASE  /*!32312 IF NOT EXISTS*/ `schooldb`  /*!40100 DEFAULT CHARACTER SET utf8 */;
  13. USE  `schooldb`;
  14. /*Table structure for table `bookmanage` */
  15. DROP TABLE IF EXISTS  `bookmanage`;
  16. CREATE TABLE  `bookmanage` (
  17.    `bid`  int( 11) NOT NULL AUTO_INCREMENT,
  18.    `bname` varchar( 40) NOT NULL,
  19.    `bauthor` varchar( 40) NOT NULL,
  20.    `btime` datetime NOT NULL,
  21.    `btype`  int( 11) NOT NULL,
  22.   PRIMARY KEY ( `bid`)
  23. ) ENGINE=InnoDB AUTO_INCREMENT= 5 DEFAULT CHARSET=utf8;
  24. /*Data for the table `bookmanage` */
  25. insert  into  `bookmanage`( `bid`, `bname`, `bauthor`, `btime`, `btype`) values ( 1, '三国演义', '罗贯中', '2021-09-08 00:00:00', 2),( 2, '水浒传', '施耐庵', '2021-09-08 00:00:00', 2),( 3, '狂人日记', '魯迅', '2021-09-08 00:00:00', 3),( 4, '改善java的151个建议', '秦少波', '2021-09-08 00:00:00', 1);
  26. /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
  27. /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
  28. /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
  29. /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

今天的分享就到这里了,明天见!

往期精彩

手把手教你搭建Maven项目

2021-02-22

java中采用异常链传递异常,既友好又方便!

2021-02-20

新春视频剪辑

2021-02-21

提倡异常封装

2021-02-19

想着看你手头宽裕的话帮我周转一下……

2021-02-17

点分享

点点赞

点在看


转载:https://blog.csdn.net/qq_34137397/article/details/113980504
查看评论
* 以上用户言论只代表其个人观点,不代表本网站的观点或立场