Java 之 Spring Boot + Vue + Element UI 前后端分离项目(上-项目搭建) 【博客论坛项目高仿CSDN

知其然不知其所以然,大厂常问面试技术如何复习?

1、热门面试题及答案大全

面试前做足功夫,让你面试成功率提升一截,这里一份热门350道一线互联网常问面试题及答案助你拿offer

2、多线程、高并发、缓存入门到实战项目pdf书籍

3、文中提到面试题答案整理

4、Java核心知识面试宝典

覆盖了JVM 、JAVA集合、JAVA多线程并发、JAVA基础、Spring原理、微服务、Netty与RPC、网络、日志、Zookeeper、Kafka、RabbitMQ、Hbase、MongoDB 、Cassandra、设计模式、负载均衡、数据库、一致性算法 、JAVA算法、数据结构、算法、分布式缓存、Hadoop、Spark、Storm的大量技术点且讲解的非常深入

本文已被CODING开源项目:【一线大厂Java面试题解析+核心总结学习笔记+最新讲解视频+实战项目源码】收录

需要这份系统化的资料的朋友,可以点击这里获取

6、编写实体类对应的mapper接口

  • BlogMapper

在这里插入图片描述

在这里插入图片描述

package cn.itbluebox.springbootcsdn.mapper;

import cn.itbluebox.springbootcsdn.domain.Blog;

import tk.mybatis.mapper.common.Mapper;

public interface BlogMapper extends Mapper {

}

其他的都类似

  • BlogArticleMapper

在这里插入图片描述

package cn.itbluebox.springbootcsdn.mapper;

import cn.itbluebox.springbootcsdn.domain.BlogArticle;

import tk.mybatis.mapper.common.Mapper;

public interface BlogArticleMapper extends Mapper {

}

  • BlogHeaderMapper

在这里插入图片描述

package cn.itbluebox.springbootcsdn.mapper;

import cn.itbluebox.springbootcsdn.domain.BlogHeader;

import tk.mybatis.mapper.common.Mapper;

public interface BlogHeaderMapper extends Mapper {

}

  • BlogHeaderMapper

在这里插入图片描述

package cn.itbluebox.springbootcsdn.mapper;

import cn.itbluebox.springbootcsdn.domain.BlogHeader;

import tk.mybatis.mapper.common.Mapper;

public interface BlogHeaderMapper extends Mapper {

}

  • BlogTypeMapper

在这里插入图片描述

在这里插入图片描述

package cn.itbluebox.springbootcsdn.mapper;

import cn.itbluebox.springbootcsdn.domain.BlogType;

import tk.mybatis.mapper.common.Mapper;

public interface BlogTypeMapper extends Mapper {

}

  • ConsumerMapper

在这里插入图片描述

package cn.itbluebox.springbootcsdn.mapper;

import cn.itbluebox.springbootcsdn.domain.Consumer;

import org.apache.ibatis.annotations.Select;

import tk.mybatis.mapper.common.Mapper;

public interface ConsumerMapper extends Mapper {

@Select(“select * from consumer where email = #{email} and password = #{password}”)

Consumer selectConsumerOne(String email, String password);

}

7、编写对应工具类

  • CookieUtils

在这里插入图片描述

package cn.itbluebox.springboottest22.utils;

import org.slf4j.Logger;

import org.slf4j.LoggerFactory;

import javax.servlet.http.Cookie;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

import java.io.UnsupportedEncodingException;

import java.net.URLDecoder;

import java.net.URLEncoder;

/**

  • Cookie 工具类

*/

public final class CookieUtils {

protected static final Logger logger = LoggerFactory.getLogger(CookieUtils.class);

/**

  • 得到Cookie的值, 不编码

  • @param request

  • @param cookieName

  • @return

*/

public static String getCookieValue(HttpServletRequest request, String cookieName) {

return getCookieValue(request, cookieName, false);

}

/**

  • 得到Cookie的值,

  • @param request

  • @param cookieName

  • @return

*/

public static String getCookieValue(HttpServletRequest request, String cookieName, boolean isDecoder) {

Cookie[] cookieList = request.getCookies();

if (cookieList == null || cookieName == null) {

return null;

}

String retValue = null;

try {

for (int i = 0; i < cookieList.length; i++) {

if (cookieList[i].getName().equals(cookieName)) {

if (isDecoder) {

retValue = URLDecoder.decode(cookieList[i].getValue(), “UTF-8”);

} else {

retValue = cookieList[i].getValue();

}

break;

}

}

} catch (UnsupportedEncodingException e) {

logger.error(“Cookie Decode Error.”, e);

}

return retValue;

}

/**

  • 得到Cookie的值,

  • @param request

  • @param cookieName

  • @return

*/

public static String getCookieValue(HttpServletRequest request, String cookieName, String encodeString) {

Cookie[] cookieList = request.getCookies();

if (cookieList == null || cookieName == null) {

return null;

}

String retValue = null;

try {

for (int i = 0; i < cookieList.length; i++) {

if (cookieList[i].getName().equals(cookieName)) {

retValue = URLDecoder.decode(cookieList[i].getValue(), encodeString);

break;

}

}

} catch (UnsupportedEncodingException e) {

logger.error(“Cookie Decode Error.”, e);

}

return retValue;

}

/**

  • 设置Cookie的值 不设置生效时间默认浏览器关闭即失效,也不编码

*/

public static void setCookie(HttpServletRequest request, HttpServletResponse response, String cookieName, String cookieValue) {

setCookie(request, response, cookieName, cookieValue, -1);

}

/**

  • 设置Cookie的值 在指定时间内生效,但不编码

*/

public static void setCookie(HttpServletRequest request, HttpServletResponse response, String cookieName, String cookieValue, int cookieMaxage) {

setCookie(request, response, cookieName, cookieValue, cookieMaxage, false);

}

/**

  • 设置Cookie的值 不设置生效时间,但编码

*/

public static void setCookie(HttpServletRequest request, HttpServletResponse response, String cookieName, String cookieValue, boolean isEncode) {

setCookie(request, response, cookieName, cookieValue, -1, isEncode);

}

/**

  • 设置Cookie的值 在指定时间内生效, 编码参数

*/

public static void setCookie(HttpServletRequest request, HttpServletResponse response, String cookieName, String cookieValue, int cookieMaxage, boolean isEncode) {

doSetCookie(request, response, cookieName, cookieValue, cookieMaxage, isEncode);

}

/**

  • 设置Cookie的值 在指定时间内生效, 编码参数(指定编码)

*/

public static void setCookie(HttpServletRequest request, HttpServletResponse response, String cookieName, String cookieValue, int cookieMaxage, String encodeString) {

doSetCookie(request, response, cookieName, cookieValue, cookieMaxage, encodeString);

}

/**

  • 删除Cookie带cookie域名

*/

public static void deleteCookie(HttpServletRequest request, HttpServletResponse response, String cookieName) {

doSetCookie(request, response, cookieName, “”, -1, false);

}

/**

  • 设置Cookie的值,并使其在指定时间内生效

  • @param cookieMaxage cookie生效的最大秒数

*/

private static final void doSetCookie(HttpServletRequest request, HttpServletResponse response, String cookieName, String cookieValue, int cookieMaxage, boolean isEncode) {

try {

if (cookieValue == null) {

cookieValue = “”;

} else if (isEncode) {

cookieValue = URLEncoder.encode(cookieValue, “utf-8”);

}

Cookie cookie = new Cookie(cookieName, cookieValue);

if (cookieMaxage > 0)

cookie.setMaxAge(cookieMaxage);

if (null != request)// 设置域名的cookie

cookie.setDomain(getDomainName(request));

cookie.setPath(“/”);

response.addCookie(cookie);

} catch (Exception e) {

logger.error(“Cookie Encode Error.”, e);

}

}

public static final Cookie setGetCookie(HttpServletRequest request, HttpServletResponse response, String cookieName, String cookieValue, int cookieMaxage, boolean isEncode) {

Cookie cookie = null;

try {

if (cookieValue == null) {

cookieValue = “”;

} else if (isEncode) {

cookieValue = URLEncoder.encode(cookieValue, “utf-8”);

}

cookie = new Cookie(cookieName, cookieValue);

if (cookieMaxage > 0)

cookie.setMaxAge(cookieMaxage);

if (null != request)// 设置域名的cookie

cookie.setDomain(getDomainName(request));

cookie.setPath(“/”);

response.addCookie(cookie);

} catch (Exception e) {

logger.error(“Cookie Encode Error.”, e);

}

return cookie;

}

/**

  • 设置Cookie的值,并使其在指定时间内生效

  • @param cookieMaxage cookie生效的最大秒数

*/

private static final void doSetCookie(HttpServletRequest request, HttpServletResponse response, String cookieName, String cookieValue, int cookieMaxage, String encodeString) {

try {

if (cookieValue == null) {

cookieValue = “”;

} else {

cookieValue = URLEncoder.encode(cookieValue, encodeString);

}

Cookie cookie = new Cookie(cookieName, cookieValue);

if (cookieMaxage > 0)

cookie.setMaxAge(cookieMaxage);

if (null != request)// 设置域名的cookie

cookie.setDomain(getDomainName(request));

cookie.setPath(“/”);

response.addCookie(cookie);

} catch (Exception e) {

logger.error(“Cookie Encode Error.”, e);

}

}

/**

  • 得到cookie的域名

*/

private static final String getDomainName(HttpServletRequest request) {

String domainName = null;

String serverName = request.getRequestURL().toString();

if (serverName == null || serverName.equals(“”)) {

domainName = “”;

} else {

serverName = serverName.toLowerCase();

serverName = serverName.substring(7);

final int end = serverName.indexOf(“/”);

serverName = serverName.substring(0, end);

final String[] domains = serverName.split(“\.”);

int len = domains.length;

if (len > 3) {

// www.xxx.com.cn

domainName = domains[len - 3] + “.” + domains[len - 2] + “.” + domains[len - 1];

} else if (len <= 3 && len > 1) {

// xxx.com or xxx.cn

domainName = domains[len - 2] + “.” + domains[len - 1];

} else {

domainName = serverName;

}

}

if (domainName != null && domainName.indexOf(“:”) > 0) {

String[] ary = domainName.split(“\:”);

domainName = ary[0];

}

return domainName;

}

}

  • IdWorker

在这里插入图片描述

package cn.itbluebox.springbootcsdn.utils;

import java.lang.management.ManagementFactory;

import java.net.InetAddress;

import java.net.NetworkInterface;

import java.util.Random;

/**

  • 名称:IdWorker.java

  • 描述:分布式自增长ID

  • Twitter的 Snowflake JAVA实现方案
    
  • 核心代码为其IdWorker这个类实现,其原理结构如下,我分别用一个0表示一位,用—分割开部分的作用:

  • 1||0—0000000000 0000000000 0000000000 0000000000 0 — 00000 —00000 —000000000000

  • 在上面的字符串中,第一位为未使用(实际上也可作为long的符号位),接下来的41位为毫秒级时间,

  • 然后5位datacenter标识位,5位机器ID(并不算标识符,实际是为线程标识),

  • 然后12位该毫秒内的当前毫秒内的计数,加起来刚好64位,为一个Long型。

  • 这样的好处是,整体上按照时间自增排序,并且整个分布式系统内不会产生ID碰撞(由datacenter和机器ID作区分),

  • 并且效率较高,经测试,snowflake每秒能够产生26万ID左右,完全满足需要。

  • 64位ID (42(毫秒)+5(机器ID)+5(业务编码)+12(重复累加))

  • @author Polim

*/

public class IdWorker {

// 时间起始标记点,作为基准,一般取系统的最近时间(一旦确定不能变动)

private final static long twepoch = 1288834974657L;

// 机器标识位数

private final static long workerIdBits = 5L;

// 数据中心标识位数

private final static long datacenterIdBits = 5L;

// 机器ID最大值

private final static long maxWorkerId = -1L ^ (-1L << workerIdBits);

// 数据中心ID最大值

private final static long maxDatacenterId = -1L ^ (-1L << datacenterIdBits);

// 毫秒内自增位

private final static long sequenceBits = 12L;

// 机器ID偏左移12位

private final static long workerIdShift = sequenceBits;

// 数据中心ID左移17位

private final static long datacenterIdShift = sequenceBits + workerIdBits;

// 时间毫秒左移22位

private final static long timestampLeftShift = sequenceBits + workerIdBits + datacenterIdBits;

private final static long sequenceMask = -1L ^ (-1L << sequenceBits);

/* 上次生产id时间戳 */

private static long lastTimestamp = -1L;

// 0,并发控制

private long sequence = 0L;

private final long workerId;

// 数据标识id部分

private final long datacenterId;

public IdWorker() {

this.datacenterId = getDatacenterId(maxDatacenterId);

this.workerId = getMaxWorkerId(datacenterId, maxWorkerId);

}

/**

  • @param workerId 工作机器ID

  • @param datacenterId 序列号

*/

public IdWorker(long workerId, long datacenterId) {

if (workerId > maxWorkerId || workerId < 0) {

throw new IllegalArgumentException(String.format(“worker Id can’t be greater than %d or less than 0”, maxWorkerId));

}

if (datacenterId > maxDatacenterId || datacenterId < 0) {

throw new IllegalArgumentException(String.format(“datacenter Id can’t be greater than %d or less than 0”, maxDatacenterId));

}

this.workerId = workerId;

this.datacenterId = datacenterId;

}

/**

  • 获取下一个ID

  • @return

*/

public synchronized long nextId() {

long timestamp = timeGen();

if (timestamp < lastTimestamp) {

throw new RuntimeException(String.format(“Clock moved backwards. Refusing to generate id for %d milliseconds”, lastTimestamp - timestamp));

}

if (lastTimestamp == timestamp) {

// 当前毫秒内,则+1

sequence = (sequence + 1) & sequenceMask;

if (sequence == 0) {

// 当前毫秒内计数满了,则等待下一秒

timestamp = tilNextMillis(lastTimestamp);

}

} else {

sequence = 0L;

}

lastTimestamp = timestamp;

// ID偏移组合生成最终的ID,并返回ID

long nextId = ((timestamp - twepoch) << timestampLeftShift)

| (datacenterId << datacenterIdShift)

| (workerId << workerIdShift) | sequence;

return nextId;

}

private long tilNextMillis(final long lastTimestamp) {

long timestamp = this.timeGen();

while (timestamp <= lastTimestamp) {

timestamp = this.timeGen();

}

return timestamp;

}

private long timeGen() {

return System.currentTimeMillis();

}

/**

  • 获取 maxWorkerId

*/

protected static long getMaxWorkerId(long datacenterId, long maxWorkerId) {

StringBuffer mpid = new StringBuffer();

mpid.append(datacenterId);

String name = ManagementFactory.getRuntimeMXBean().getName();

if (!name.isEmpty()) {

/*

  • GET jvmPid

*/

mpid.append(name.split(“@”)[0]);

}

/*

  • MAC + PID 的 hashcode 获取16个低位

*/

return (mpid.toString().hashCode() & 0xffff) % (maxWorkerId + 1);

}

/**

  • 数据标识id部分

*/

protected static long getDatacenterId(long maxDatacenterId) {

long id = 0L;

try {

InetAddress ip = InetAddress.getLocalHost();

NetworkInterface network = NetworkInterface.getByInetAddress(ip);

if (network == null) {

id = 1L;

} else {

byte[] mac = network.getHardwareAddress();

id = ((0x000000FF & (long) mac[mac.length - 1])

| (0x0000FF00 & (((long) mac[mac.length - 2]) << 8))) >> 6;

id = id % (maxDatacenterId + 1);

}

} catch (Exception e) {

System.out.println(" getDatacenterId: " + e.getMessage());

}

return id;

}

public static void main(String[] args) {

IdWorker idWorker = new IdWorker(new Random().nextInt(10), 1);

long l = idWorker.nextId();

System.out.println(l);

}

}

  • JwtConstants

在这里插入图片描述

package cn.itbluebox.springbootcsdn.utils;

public class JwtConstants {

public static final String JWT_KEY_ID = “id”;

public static final String JWT_KEY_EMAIL = “email”;

public static final String JWT_KEY_NAME = “name”;

public static final String JWT_KEY_IMG = “image”;

}

  • JwtUtils

在这里插入图片描述

package cn.itbluebox.springbootcsdn.utils;

import io.jsonwebtoken.Claims;

import io.jsonwebtoken.Jws;

import io.jsonwebtoken.Jwts;

import io.jsonwebtoken.SignatureAlgorithm;

import org.joda.time.DateTime;

import java.security.PrivateKey;

import java.security.PublicKey;

public class JwtUtils {

/**

  • 生成Token

  • @param userInfo

  • @param privateKey

  • @param expireMinutes

  • @return

*/

public static String generateToken(UserInfo userInfo, PrivateKey privateKey, int expireMinutes) {

return Jwts.builder()

.claim(JwtConstants.JWT_KEY_ID, userInfo.getId())

.claim(JwtConstants.JWT_KEY_NAME, userInfo.getName())

.claim(JwtConstants.JWT_KEY_IMG, userInfo.getImage())

.claim(JwtConstants.JWT_KEY_EMAIL, userInfo.getEmail())

.setExpiration(DateTime.now().plusMinutes(expireMinutes).toDate())

.signWith(SignatureAlgorithm.RS256, privateKey)

.compact();

}

/**

  • 生成Token

  • @param userInfo

  • @param privateKey

  • @param expireMinutes

  • @return

  • @throws Exception

*/

public static String generateToken(UserInfo userInfo, byte[] privateKey, int expireMinutes) throws Exception {

return Jwts.builder()

.claim(JwtConstants.JWT_KEY_ID, userInfo.getId())

.claim(JwtConstants.JWT_KEY_NAME, userInfo.getName())

.claim(JwtConstants.JWT_KEY_IMG, userInfo.getImage())

.claim(JwtConstants.JWT_KEY_EMAIL, userInfo.getEmail())

.setExpiration(DateTime.now().plusMinutes(expireMinutes).toDate())

.signWith(SignatureAlgorithm.ES256, RsaUtils.getPrivateKey(privateKey))

.compact();

}

/**

  • 公钥解析Token

  • @param publicKey

  • @param token

  • @return

*/

public static Jws parseToken(PublicKey publicKey, String token) {

return Jwts.parser().setSigningKey(publicKey).parseClaimsJws(token);

}

/**

  • 公钥解析Token

  • @param publicKey

  • @param token

  • @return

  • @throws Exception

*/

public static Jws parseToken(byte[] publicKey, String token) throws Exception {

return Jwts.parser().setSigningKey(RsaUtils.getPublicKey(publicKey)).parseClaimsJws(token);

}

/**

  • 从Token中获取用户信息(使用公钥解析)

  • @param publicKey

  • @param token

  • @return

*/

public static UserInfo getUserInfo(PublicKey publicKey, String token) {

Jws claimsJws = parseToken(publicKey, token);

Claims body = claimsJws.getBody();

return new UserInfo(

ObjectUtils.toLong(body.get(JwtConstants.JWT_KEY_ID)),

ObjectUtils.toString(body.get(JwtConstants.JWT_KEY_NAME)),

ObjectUtils.toString(body.get(JwtConstants.JWT_KEY_EMAIL)),

ObjectUtils.toString(body.get(JwtConstants.JWT_KEY_IMG))

);

}

/**

  • 从Token中获取用户信息(使用公钥解析)

  • @param publicKey

  • @param token

  • @return

  • @throws Exception

*/

public static UserInfo getUserInfo(byte[] publicKey, String token) throws Exception {

Jws claimsJws = parseToken(publicKey, token);

Claims body = claimsJws.getBody();

return new UserInfo(

ObjectUtils.toLong(body.get(JwtConstants.JWT_KEY_ID)),

ObjectUtils.toString(body.get(JwtConstants.JWT_KEY_NAME)),

ObjectUtils.toString(body.get(JwtConstants.JWT_KEY_IMG)),

ObjectUtils.toString(body.get(JwtConstants.JWT_KEY_EMAIL))

);

}

}

  • LongJSONArray

在这里插入图片描述

package cn.itbluebox.springbootcsdn.utils;

import com.alibaba.fastjson.JSON;

import com.alibaba.fastjson.JSONArray;

public class LongJSONArray {

public static String LongToJSON(Long l[]) {

StringBuilder sb = new StringBuilder(JSONArray.toJSONString(l));

sb.replace(0, 1, “”);

sb.replace(sb.length() - 1, sb.length(), “”);

return sb.toString();

}

public static Long[] JSONToLong(String l) {

l = “[” + l + “]”;

Long[] longs = JSON.parseObject(l, Long[].class);

return longs;

}

}

  • ObjectUtils

在这里插入图片描述

package cn.itbluebox.springbootcsdn.utils;

import org.apache.commons.lang3.StringUtils;

public class ObjectUtils {

public static String toString(Object obj) {

if (obj == null) {

return null;

}

return obj.toString();

}

public static Long toLong(Object obj) {

if (obj == null) {

return 0L;

}

if (obj instanceof Double || obj instanceof Float) {

return Long.valueOf(StringUtils.substringBefore(obj.toString(), “.”));

}

if (obj instanceof Number) {

return Long.valueOf(obj.toString());

}

if (obj instanceof String) {

return Long.valueOf(obj.toString());

} else {

return 0L;

}

}

public static Integer toInt(Object obj) {

return toLong(obj).intValue();

}

}

  • RandomAdmin

package cn.itbluebox.springbootcsdn.utils;

import java.text.NumberFormat;

import java.util.Random;

public class RandomAdmin {

public static double RandmoncreateMoney() {

int max = 100, min = 1;

int ran1 = (int) (Math.random() * (max - min) + min);

double max1 = 10, min1 = 1;

double ran2 = (double) (Math.random() * (max1 - min1) + min1);

NumberFormat nf = NumberFormat.getNumberInstance();

nf.setMaximumFractionDigits(2);

return Double.parseDouble(nf.format(ran1 + ran2));

}

private static final int BASE_RANDOM = 0x9fa5 - 0x4e00 + 1;

private static Random random = new Random();

public static char RandomString(){

return (char) (0x4e00 + random.nextInt(BASE_RANDOM));

}

public static String RandomString(int num){

String str = “”;

for(int i = 0; i < num; i++){

str += (char) (0x4e00 + random.nextInt(BASE_RANDOM));

}

return str;

}

}

  • RsaUtils

package cn.itbluebox.springbootcsdn.utils;

import java.io.File;

import java.io.IOException;

import java.nio.file.Files;

import java.security.*;

import java.security.spec.PKCS8EncodedKeySpec;

import java.security.spec.X509EncodedKeySpec;

public class RsaUtils {

/**

  • 从文件中读取公钥

  • @param filename 公钥保存路径,相对于classpath

  • @return 公钥对象

  • @throws Exception

*/

public static PublicKey getPublicKey(String filename) throws Exception {

byte[] bytes = readFile(filename);

return getPublicKey(bytes);

}

/**

  • 从文件中读取密钥

  • @param filename 私钥保存路径,相对于classpath

  • @return 私钥对象

  • @throws Exception

*/

public static PrivateKey getPrivateKey(String filename) throws Exception {

byte[] bytes = readFile(filename);

return getPrivateKey(bytes);

}

/**

  • 获取公钥

  • @param bytes 公钥的字节形式

  • @return

  • @throws Exception

*/

public static PublicKey getPublicKey(byte[] bytes) throws Exception {

X509EncodedKeySpec spec = new X509EncodedKeySpec(bytes);

KeyFactory factory = KeyFactory.getInstance(“RSA”);

return factory.generatePublic(spec);

}

/**

  • 获取密钥

  • @param bytes 私钥的字节形式

  • @return

  • @throws Exception

*/

public static PrivateKey getPrivateKey(byte[] bytes) throws Exception {

PKCS8EncodedKeySpec spec = new PKCS8EncodedKeySpec(bytes);

KeyFactory factory = KeyFactory.getInstance(“RSA”);

return factory.generatePrivate(spec);

}

/**

  • 根据密文,生存rsa公钥和私钥,并写入指定文件

  • @param publicKeyFilename 公钥文件路径

  • @param privateKeyFilename 私钥文件路径

  • @param secret 生成密钥的密文

  • @throws IOException

  • @throws NoSuchAlgorithmException

*/

public static void generateKey(String publicKeyFilename, String privateKeyFilename, String secret) throws Exception {

KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance(“RSA”);

SecureRandom secureRandom = new SecureRandom(secret.getBytes());

keyPairGenerator.initialize(1024, secureRandom);

KeyPair keyPair = keyPairGenerator.genKeyPair();

// 获取公钥并写出

byte[] publicKeyBytes = keyPair.getPublic().getEncoded();

writeFile(publicKeyFilename, publicKeyBytes);

// 获取私钥并写出

byte[] privateKeyBytes = keyPair.getPrivate().getEncoded();

writeFile(privateKeyFilename, privateKeyBytes);

}

private static byte[] readFile(String fileName) throws Exception {

return Files.readAllBytes(new File(fileName).toPath());

}

private static void writeFile(String destPath, byte[] bytes) throws IOException {

File dest = new File(destPath);

if (!dest.exists()) {

dest.createNewFile();

}

Files.write(dest.toPath(), bytes);

}

}

  • StringPaseDate

package cn.itbluebox.springbootcsdn.utils;

import java.util.Calendar;

import java.util.Date;

public class StringPaseDate {

public static Date getDate(String str_date){

String[] split = str_date.split(“-”);

Calendar calendar=Calendar.getInstance();

calendar.set(Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2]));

return calendar.getTime();

}

}

  • TimeForMate

package cn.itbluebox.springbootcsdn.utils;

import java.text.SimpleDateFormat;

import java.util.Date;

public class TimeForMate {

public static String forMate(String dateStr) {

SimpleDateFormat dateFormat = new SimpleDateFormat(“yyyy-MM-dd”);

Date date = new Date();

date.setTime(Long.parseLong(dateStr));

return dateFormat.format(date);

}

}

  • UserInfo

package cn.itbluebox.springbootcsdn.utils;

import lombok.AllArgsConstructor;

import lombok.Data;

import lombok.NoArgsConstructor;

@Data

@NoArgsConstructor

@AllArgsConstructor

public class UserInfo {

private Long id;

private String name;

private String image;

private String email;

}

8、创建PageResult

在这里插入图片描述

package cn.itbluebox.springbootcsdn.vo;

import lombok.Data;

import java.util.List;

@Data

public class PageResult {

private Long total;//总条数

private Integer totalPage;//总页数

private List items;//当前页数据

public PageResult() {

}

public PageResult(Long total, List items){

this.total = total;

this.items = items;

}

public PageResult(Long total, Integer totalPage, List items) {

this.total = total;

this.totalPage = totalPage;

this.items = items;

}

}

三、前端Vue + Element UI项目搭建


1、项目搭建

(1)项目构建

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

使用 Vue-cli构建 Vue 项目

安装命令:

在这里插入图片描述

感受:

其实我投简历的时候,都不太敢投递阿里。因为在阿里一面前已经过了字节的三次面试,投阿里的简历一直没被捞,所以以为简历就挂了。

特别感谢一面的面试官捞了我,给了我机会,同时也认可我的努力和态度。对比我的面经和其他大佬的面经,自己真的是运气好。别人8成实力,我可能8成运气。所以对我而言,我要继续加倍努力,弥补自己技术上的不足,以及与科班大佬们基础上的差距。希望自己能继续保持学习的热情,继续努力走下去。

也祝愿各位同学,都能找到自己心动的offer。

分享我在这次面试前所做的准备(刷题复习资料以及一些大佬们的学习笔记和学习路线),都已经整理成了电子文档

拿到字节跳动offer后,简历被阿里捞了起来,二面迎来了P9"盘问"

本文已被CODING开源项目:【一线大厂Java面试题解析+核心总结学习笔记+最新讲解视频+实战项目源码】收录

需要这份系统化的资料的朋友,可以点击这里获取

import java.util.List;

@Data

public class PageResult {

private Long total;//总条数

private Integer totalPage;//总页数

private List items;//当前页数据

public PageResult() {

}

public PageResult(Long total, List items){

this.total = total;

this.items = items;

}

public PageResult(Long total, Integer totalPage, List items) {

this.total = total;

this.totalPage = totalPage;

this.items = items;

}

}

三、前端Vue + Element UI项目搭建


1、项目搭建

(1)项目构建

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

使用 Vue-cli构建 Vue 项目

安装命令:

在这里插入图片描述

感受:

其实我投简历的时候,都不太敢投递阿里。因为在阿里一面前已经过了字节的三次面试,投阿里的简历一直没被捞,所以以为简历就挂了。

特别感谢一面的面试官捞了我,给了我机会,同时也认可我的努力和态度。对比我的面经和其他大佬的面经,自己真的是运气好。别人8成实力,我可能8成运气。所以对我而言,我要继续加倍努力,弥补自己技术上的不足,以及与科班大佬们基础上的差距。希望自己能继续保持学习的热情,继续努力走下去。

也祝愿各位同学,都能找到自己心动的offer。

分享我在这次面试前所做的准备(刷题复习资料以及一些大佬们的学习笔记和学习路线),都已经整理成了电子文档

[外链图片转存中…(img-HbuhoOKm-1715287422377)]

本文已被CODING开源项目:【一线大厂Java面试题解析+核心总结学习笔记+最新讲解视频+实战项目源码】收录

需要这份系统化的资料的朋友,可以点击这里获取

  • 16
    点赞
  • 22
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
本文介绍了一个基于Spring BootSpring Cloud和Vue前后端分离项目实战。这个项目是一个简单的在线商城,包含了用户注册、登录、商品展示、购物车、订单管理等功能。通过这个项目,读者可以深入理解前后端分离的架构模式和互联网应用的开发方式。 首先,文章介绍了前后端分离的基本概念和优势。前后端分离是将应用的前端和后端代码分开来开发,使得前端和后端具有独立的开发周期和技术栈,进而提高了开发效率和代码质量。同时,前后端分离还可以提供更好的用户体验和灵活性,对于互联网应用来说尤为重要。 接下来,文章介绍了项目的架构和技术栈。项目采用了Spring BootSpring Cloud框架来实现后端代码,采用MyBatis作为ORM框架和Redis作为缓存中间件。同时,项目还采用了Vue.js作为前端框架和Element UI组件库来实现前端页面。通过这些开源框架和组件,可以快速搭建一个前后端分离的互联网应用。 然后,文章介绍了项目的核心功能和代码实现。在用户注册和登录方面,项目采用了Spring Security框架和JWT令牌来实现用户认证和授权,保证了用户信息的安全性。在商品展示和购物车方面,项目采用了Vue.js来实现前端页面和事件处理。在订单管理方面,项目采用了MyBatis Plus来实现订单数据的持久化和分页查询。 最后,文章介绍了项目的测试和优化。通过对项目的压力测试和性能测试,文章发现项目还存在一些性能瓶颈和安全隐患,可以通过优化数据库查询、缓存配置和代码实现来提高应用的性能和安全性。 总之,这篇文章介绍了一个基于Spring BootSpring Cloud和Vue前后端分离项目实战,通过实现一个在线商城的功能,展示了前后端分离的开发模式和互联网应用的开发技术栈。本文可以作为前后端分离开发的入门教程,也可以作为互联网应用开发的参考文档。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值