098天
行百里者半九十,想要在一个行业里成为顶尖人才,一定满足一万小时定律,要想学好JAVA,需要持之以恒不断地努力,每天都要勤思考+善于询问+解决问题!
知识温故而知新>>>>>>
IDEA显示同时显示多个项目的方法
打开IDEA, 点击File....


选择需要导入的项目,项目名会自动更改

点击YES

选择POM文件,更新Mvaen项目需要地第三方类库

运行所选项目即可
今天学到的知识>>>>>>


idea中配置maven

IDEA打包maven项目到JAR包和安装到本地仓库的方法

UsersController
package com.bjsxt.springbootmybatis.controller;
import com.bjsxt.springbootmybatis.pojo.Users;
import com.bjsxt.springbootmybatis.service.UsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* 用户管理Controller
*/
@Controller
@RequestMapping("/user")
public class UsersController {
@Autowired
private UsersService usersService;
/**
* 添加用户
*/
@RequestMapping("/addUser")
public String addUsers(Users users){
try{
this.usersService.addUsers(users);
}catch(Exception e){
e.printStackTrace();
return "error";
}
return "redirect:/ok";
}
/**
* 查询全部用户
*/
@RequestMapping("/findUserAll")
public String findUserAll(Model model){
try{
List<Users> list = this.usersService.findUserAll();
model.addAttribute("list",list);
}catch(Exception e){
e.printStackTrace();
return "error";
}
return "showUsers";
}
/**
* 预更新用户查询
*/
@RequestMapping("/preUpdateUser")
public String preUpdateUser(Integer id,Model model){
try{
Users user = this.usersService.preUpdateUsers(id);
model.addAttribute("user",user);
}catch(Exception e){
e.printStackTrace();
return "error";
}
return "updateUser";
}
/**
* 更新用户
*/
@RequestMapping("/updateUser")
public String updateUser(Users users){
try{
this.usersService.modifyUsers(users);
}catch(Exception e){
e.printStackTrace();
return "error";
}
return "redirect:/ok";
}
/**
* 删除用户
*/
@RequestMapping("/deleteUser")
public String deleteUser(Integer id){
try{
this.usersService.dropUsersById(id);
}catch(Exception e){
e.printStackTrace();
return "error";
}
return "redirect:/ok";
}
}
generatorConfig.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE generatorConfiguration
PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<generatorConfiguration>
<context id="testTables" targetRuntime="MyBatis3">
<commentGenerator>
<!-- 是否去除自动生成的注释 true:是 : false:否 -->
<property name="suppressAllComments" value="true" />
</commentGenerator>
<!--数据库连接的信息:驱动类、连接地址、用户名、密码 -->
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://localhost:3306/anlan" userId="root"
password="xianyu">
</jdbcConnection>
<!-- 默认false,把JDBC DECIMAL 和 NUMERIC 类型解析为 Integer,为 true时把JDBC DECIMAL 和
NUMERIC 类型解析为java.math.BigDecimal -->
<javaTypeResolver>
<property name="forceBigDecimals" value="false" />
</javaTypeResolver>
<!-- targetProject:生成PO类的位置 -->
<javaModelGenerator targetPackage="com.bjsxt.springbootmybatis.pojo"
targetProject=".\src\main\java">
<!-- enableSubPackages:是否让schema作为包的后缀 -->
<property name="enableSubPackages" value="false" />
<!-- 从数据库返回的值被清理前后的空格 -->
<property name="trimStrings" value="true" />
</javaModelGenerator>
<!-- targetProject:mapper映射文件生成的位置 -->
<sqlMapGenerator targetPackage="com.bjsxt.springbootmybatis.mapper"
targetProject=".\src\main\java">
<!-- enableSubPackages:是否让schema作为包的后缀 -->
<property name="enableSubPackages" value="false" />
</sqlMapGenerator>
<!-- targetPackage:mapper接口生成的位置 -->
<javaClientGenerator type="XMLMAPPER"
targetPackage="com.bjsxt.springbootmybatis.mapper"
targetProject=".\src\main\java">
<!-- enableSubPackages:是否让schema作为包的后缀 -->
<property name="enableSubPackages" value="false" />
</javaClientGenerator>
<!-- 指定数据库表 -->
<table schema="" tableName="users"></table>
</context>
</generatorConfiguration>
网友评论