发表于: 2020-06-18 23:13:21
1 1888
今天完成的事情:
1.本地配置nginx
在mac命令界面操作(linux同样)
第一步:安装homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
第二步:安装nginx
brew install nginx
这两步完全就是碰运气下载,下载速度巨慢,还总下载失败。
第三步:查看nginx安装目录brew info nginx
//1.查找nginx.conf 配置文件
cd /usr/local/etc/nginx
cat nginx.cong
或者
open cd /usr/local/etc/nginx
//2.查看nginx的安装目录
cd /usr/local/Cellar/nginx
//3.查看nginx的运行静态目录
cd /usr/local/var/www
第四步:nginx的启动、重启、停止
//找到nginx的启动命令目录/usr/local/Cellar/nginx/1.15.9/bin
nginx
//启动nginx -s reload
//重启nginx -s stop
//停止ps:查看关于nginx的命令
nginx -h
2.自动生成实体类,mapper,mapper.xml
(1)配置pom.xml
<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-core</artifactId>
<version>1.3.5</version>
</dependency>
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.5</version>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.18</version>
</dependency>
</dependencies>
<configuration>
<!-- mybatis用于生成代码的配置文件 -->
<configurationFile>src/main/resources/generatorConfig.xml</configurationFile>
<verbose>true</verbose>
<overwrite>true</overwrite>
</configuration>
</plugin>
(2)添加配置文件
<?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="DB2Tables" targetRuntime="MyBatis3">
<commentGenerator>
<property name="suppressDate" value="true"/>
<!-- 是否去除自动生成的注释 true:是 : false:否 -->
<property name="suppressAllComments" value="true"/>
</commentGenerator>
<!--数据库链接URL,用户名、密码 -->
<jdbcConnection driverClass="com.mysql.cj.jdbc.Driver"
connectionURL="jdbc:mysql://localhost:3306/art_studio?characterEncoding=UTF-8"
userId="root"
password="19980710">
</jdbcConnection>
<javaTypeResolver>
<property name="forceBigDecimals" value="false"/>
</javaTypeResolver>
<!-- 生成模型的包名和位置-->
<javaModelGenerator targetPackage="com.artstudio.dao.pojo" targetProject="./src/main/java">
<property name="enableSubPackages" value="true"/>
<property name="trimStrings" value="true"/>
</javaModelGenerator>
<!-- 生成映射文件的包名和位置-->
<sqlMapGenerator targetPackage="com.artstudio.dao.mapper" targetProject="./src/main/java">
<property name="enableSubPackages" value="true"/>
</sqlMapGenerator>
<!-- 生成mapper位置-->
<javaClientGenerator type="XMLMAPPER" targetPackage="com.artstudio.dao.mapper" targetProject="./src/main/java">
<property name="enableSubPackages" value="true"/>
</javaClientGenerator>
<!-- 要生成的表 tableName是数据库中的表名或视图名 domainObjectName是实体类名-->
<table tableName="art" domainObjectName="Art"
enableCountByExample="false" enableUpdateByExample="false"
enableDeleteByExample="false" enableSelectByExample="false"
selectByExampleQueryId="false">
</table>
<table tableName="banner" domainObjectName="Banner"
enableCountByExample="false" enableUpdateByExample="false"
enableDeleteByExample="false" enableSelectByExample="false"
selectByExampleQueryId="false">
</table>
<table tableName="message" domainObjectName="Message"
enableCountByExample="false" enableUpdateByExample="false"
enableDeleteByExample="false" enableSelectByExample="false"
selectByExampleQueryId="false">
</table>
<table tableName="module" domainObjectName="Module"
enableCountByExample="false" enableUpdateByExample="false"
enableDeleteByExample="false" enableSelectByExample="false"
selectByExampleQueryId="false">
</table>
<table tableName="art_type" domainObjectName="ArtType"
enableCountByExample="false" enableUpdateByExample="false"
enableDeleteByExample="false" enableSelectByExample="false"
selectByExampleQueryId="false">
</table>
<table tableName="role" domainObjectName="Role"
enableCountByExample="false" enableUpdateByExample="false"
enableDeleteByExample="false" enableSelectByExample="false"
selectByExampleQueryId="false">
</table>
<table tableName="studio_details" domainObjectName="StudioDetails"
enableCountByExample="false" enableUpdateByExample="false"
enableDeleteByExample="false" enableSelectByExample="false"
selectByExampleQueryId="false">
</table>
<table tableName="role_module" domainObjectName="RoleModule"
enableCountByExample="false" enableUpdateByExample="false"
enableDeleteByExample="false" enableSelectByExample="false"
selectByExampleQueryId="false">
</table>
</context>
</generatorConfiguration>
(3)maven运行
3.login
package com.artstudio.controller;
import com.artstudio.dao.pojo.User;
import com.artstudio.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import javax.servlet.http.HttpSession;
/**
* Created with IntelliJ IDEA.
*
* @author: WangPeng
* @date: 2020/06/16/7:05 下午
* @description:
*/
@Controller
@RequestMapping("/login")
public class LoginController {
@Autowired(required = false)
private UserService userService;
@RequestMapping(value = "/logView")
public String loginView() {
return "login";
}
@RequestMapping(value = "/log", method = RequestMethod.POST)
public String login(User user, HttpSession session) {
User logUser = userService.loginService(user);
if (logUser != null) {
session.setAttribute("logUser", user);
return "success";
}
return "login";
}
}
明天计划的事情:
继续完成其他模块的增删改查
遇到的问题:
错误信息的显示还是要找一找
收获:
1.学会自动生成实体类,mapper,mapper.xml
2.学会登录注册的简单实现
3.终于在本地配置好了nginx
评论