一:整合jpa完成mysql8连接:
1.pom文件:
<groupId>org.springframework.bootgroupId> <artifactId>spring-boot-starter-testartifactId> <scope>testscope> dependency> <dependency> <groupId>org.projectlombokgroupId> <artifactId>lombokartifactId> <version>1.18.4version> dependency> dependencies> <build> <plugins> <plugin> <groupId>org.springframework.bootgroupId> <artifactId>spring-boot-maven-pluginartifactId> plugin> plugins> build>project>
2.application.yml:
spring: jpa: # 默认false,在日志里显示执行的sql语句 show-sql: true database: mysql #指定为update,每次启动项目检测表结构有变化的时候会新增字段,表不存在时会新建,如果指定create,则每次启动项目都会清空数据并删除表,再新建 hibernate.ddl-auto: update properties.hibernate.dialect: org.hibernate.dialect.MySQL5Dialect database-platform: org.hibernate.dialect.MySQL5Dialect hibernate: naming: #physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl #指定jpa的自动表生成策略,驼峰自动映射为下划线格式 implicit-strategy: org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyJpaImpl datasource: username: root password: ROOTroot #同样 低版本的MySql不需要指定时区 url: jdbc:mysql://127.0.0.1:3306/dd?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&useSSL=false #mysql8.0以后的加密方式为caching_sha2_password,所以必须用com.mysql.cj.jdbc.Driver,前提是pom里引入的mysql-connector-java必须为8.0.12的,8.0.13不行,会报错 driver-class-name: com.mysql.cj.jdbc.Driver #如果是老版本的MySql,或者手动修改my.ini指定加密方式为mysql_native_password,则使用原来的Driver即可 #driver-class-name: com.mysql.jdbc.Driver type: com.zaxxer.hikari.HikariDataSource #自己的连接池配置 hikari: pool-name: user-1 minimum-idle: 30 maximum-pool-size: 30 connectionTimeout: 60000 idleTimeout: 60000 validationTimeout: 3000 maxLifetime: 60000 register-mbeans: true
3.user:
package com.example.demo.entity;import javax.persistence.Entity;import com.fasterxml.jackson.annotation.JsonIgnoreProperties;import javax.persistence.*;@Entity@Table(name = "user")@JsonIgnoreProperties({"handler","hibernateLazyInitializer"})public class User { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "id") int id; String username; 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; }}
4.userdao:
package com.example.demo.dao;import com.example.demo.entity.User;import org.springframework.data.jpa.repository.JpaRepository;public interface UserDAO extends JpaRepository<User,Integer> { User findByUsername(String username); User getByUsernameAndPassword(String username,String password);}
5.userservice:
package com.example.demo.service;import com.example.demo.dao.UserDAO;import com.example.demo.entity.User;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Service;@Servicepublic class UserService { @Autowired UserDAO userDAO; public boolean isExist(String username) { User user = getByName(username); return null!=user; } public User getByName(String username) { return userDAO.findByUsername(username); } public User get(String username, String password){ return userDAO.getByUsernameAndPassword(username, password); } public void add(User user) { userDAO.save(user); }}
6.controller:
package com.example.demo.controller;import com.example.demo.entity.User;import com.example.demo.service.UserService;import com.example.demo.utils.Result;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.CrossOrigin;import org.springframework.web.bind.annotation.PostMapping;import org.springframework.web.bind.annotation.RequestBody;import org.springframework.web.bind.annotation.ResponseBody;import org.springframework.web.util.HtmlUtils;@Controllerpublic class LoginController { @Autowired UserService userService; @CrossOrigin @PostMapping(value = "/api/login") @ResponseBody public Result login(@RequestBody User requestUser) { String username = requestUser.getUsername(); username = HtmlUtils.htmlEscape(username); User user = userService.get(username, requestUser.getPassword()); if (null == user) { return new Result(400); } else { return new Result(200); } }}
7.result:
package com.example.demo.utils;public class Result { //响应码 private int code; public Result(int code) { this.code = code; } public int getCode() { return code; } public void setCode(int code) { this.code = code; }}
二:elementui:
1.安装elementui:
2.elementui引入(在main.js里面)
import ElementUI from 'element-ui'import 'element-ui/lib/theme-chalk/index.css'Vue.use(ElementUI)
3.登陆界面优化
<template> <body id="poster"> <el-form class="login-container" label-position="left" label-width="0px"> <h3 class="login_title">系统登录h3> <el-form-item> <el-input type="text" v-model="loginForm.username" auto-complete="off" placeholder="账号">el-input> el-form-item> <el-form-item> <el-input type="password" v-model="loginForm.password" auto-complete="off" placeholder="密码">el-input> el-form-item> <el-form-item style="width: 100%"> <el-button type="primary" style="width: 100%;background: #505458;border: none" v-on:click="login">登录el-button> el-form-item> el-form> body>template><script>export default { name: 'Login', data () { return { loginForm: { username: '', password: '' }, responseResult: [] } }, methods: { login () { this.$axios .post('/login', { username: this.loginForm.username, password: this.loginForm.password }) .then(successResponse => { if (successResponse.data.code === 200) { this.$router.replace({path: '/index'}) } }) .catch(failResponse => { }) } }}script><style>.login-container { border-radius: 15px; background-clip: padding-box; margin: 90px auto; width: 350px; padding: 35px 35px 15px 35px; background: #fff; border: 1px solid #eaeaea; box-shadow: 0 0 25px #cac6c6;}.login_title { margin: 0px auto 40px auto; text-align: center; color: #505458;}#poster { background:url("../assets/eva.jpg") no-repeat; background-position: center; height: 100%; width: 100%; background-size: cover; position: fixed;}body{ margin: 0px;}style>
4.效果
三:oracle相关信息
包:https://www.oracle.com/database/technologies/oracle-database-software-downloads.html安装:https://blog.csdn.net/weixin_43465312/article/details/95187554配置:https://blog.csdn.net/weixin_43867817/article/details/106548573卸载:https://blog.csdn.net/java_peak_zlf/article/details/89715202创建用户:ORACLE创建新用户和表空间:1.打开sql plus输入用户名system,密码Aa0000002.create user username identified by password;如果显示错误,在username前面加c##3.创建表空间的位置和大小create tablespace 表空间名 datafile ‘F:\APP\AEH\ORADATA\ORCL\表空间名.dbf’ size 1024m;4.alter user username default tablespace 表空间名;5.grant create session,create table,unlimited tablespace to username;6.此时报错,可以重启服务7,显示用户锁定select * from dba_profiles where RESOURCE_NAME='FAILED_LOGIN_ATTEMPTS'; ALTER USER 用户名 ACCOUNT UNLOCK;alter profile default limit failed_login_attempts unlimited;--不限制连接数alter profile DEFAULT limit FAILED_LOGIN_ATTEMPTS 1000; --设定用户连接失败数超过1000次之后自动锁住连接别人oracle:修改别人F:\app\aeh\product\12.2.0\dbhome_1\network\admin里面的localhost为机器名
----end
注意点:Element 的官方地址为 http://element-cn.eleme.io/#/zh-CN