正则采集器之二——后台搭建

news2024/9/9 4:29:48

本人是java程序员,所以使用java界流行的架构来搭建后台。后台使用java作为后端语言,mysql作为数据库,redis作为缓存中间件。采用SpringBoot作为java端依赖管理、bean生命周期管理的容器,mybatis作为数据库持久化框架,shiro作为鉴权框架。

1、新建maven项目

命名为reptile,接着加入依赖:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <parent>
	    <groupId>org.springframework.boot</groupId>
	    <artifactId>spring-boot-starter-parent</artifactId>
	    <version>2.4.2</version>
	</parent>
  
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.learn.reptile</groupId>
  <artifactId>reptile</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  
  <properties>
    <java.version>1.8</java.version>
    <mybatis.plus.version>3.4.2</mybatis.plus.version>
    <druid.version>1.1.18</druid.version>
    <mysql.version>8.0.13</mysql.version>
    <!--<log4j.version>1.2.17</log4j.version>-->

    <hutool.version>5.5.8</hutool.version>
    <guava.version>28.1-jre</guava.version>
    
    <shiro.version>1.13.0</shiro.version>
	<httpclient.version>4.5.3</httpclient.version>
  </properties>
  
  <dependencies>
        <!-- Druid引入 -->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid-spring-boot-starter</artifactId>
            <version>${druid.version}</version>
        </dependency>

        <!-- 数据源驱动 -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>${mysql.version}</version>
        </dependency>
        
        <!-- mybatis-plus依赖 -->
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>${mybatis.plus.version}</version>
        </dependency>
        
        <dependency>
	        <groupId>org.springframework.boot</groupId>
	        <artifactId>spring-boot-starter-web</artifactId>
	        <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-logging</artifactId>
                </exclusion>
            </exclusions>
	    </dependency>
	    
	    <dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-log4j2</artifactId>
			<version>2.4.2</version>
		</dependency>
		
		  <!-- spring-boot-starter-data-redis -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-aop</artifactId>
        </dependency>

        <dependency>
            <groupId>redis.clients</groupId>
            <artifactId>jedis</artifactId>
        </dependency>
        
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <!--            <optional>true</optional>-->
        </dependency>
        
         <!-- guava支持 -->
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>${guava.version}</version>
        </dependency>

        <dependency>
            <groupId>com.alibaba.fastjson2</groupId>
            <artifactId>fastjson2</artifactId>
            <version>2.0.13</version>
        </dependency>
        
        
	    <dependency>
	        <groupId>org.springframework.boot</groupId>
	        <artifactId>spring-boot-devtools</artifactId>
	        <scope>runtime</scope>
	        <optional>true</optional>
	    </dependency>
	    
	     <!--        shiro 核心类库-->
	    <dependency>
		    <groupId>org.apache.shiro</groupId>
		    <artifactId>shiro-core</artifactId>
		    <version>${shiro.version}</version>
	    </dependency>
	    <!-- shiro 整合sping -->
	    <dependency>
	        <groupId>org.apache.shiro</groupId>
	        <artifactId>shiro-spring</artifactId>
	        <version>${shiro.version}</version>
	    </dependency>
	
	    <!-- 日志框架依赖 -->
	    <!--<dependency>
	        <groupId>log4j</groupId>
	        <artifactId>log4j</artifactId>
	        <version>${log4j.version}</version>
	    </dependency>-->
	
	    <dependency>
	        <groupId>org.apache.httpcomponents</groupId>
	        <artifactId>httpclient</artifactId>
	        <version>${httpclient.version}</version>
	    </dependency>
	    
	    <dependency>
			<groupId>cn.hutool</groupId>
			<artifactId>hutool-all</artifactId>
			<version>${hutool.version}</version>
		</dependency>
        
         <!--        okhttp依赖-->
        <dependency>
            <groupId>com.squareup.okhttp3</groupId>
            <artifactId>okhttp</artifactId>
            <version>4.9.1</version>
        </dependency>
	</dependencies>
	
	 <build>
	    <resources>
	        <resource>
	            <directory>src/main/resources</directory>
	            <filtering>true</filtering>
	        </resource>
	        <resource>
	            <directory>src/main/java</directory>
	            <includes>
	                <include>**/*.xml</include>
	            </includes>
	        </resource>
	    </resources>
	    
	    <plugins>
	        <plugin>
	            <groupId>org.apache.maven.plugins</groupId>
	            <artifactId>maven-compiler-plugin</artifactId>
	            <configuration>
	                <source>8</source>
	                <target>8</target>
	            </configuration>
	        </plugin>
			 
			 <plugin>
	            <groupId>org.springframework.boot</groupId>
	            <artifactId>spring-boot-maven-plugin</artifactId>
	            <configuration>
	                <includeSystemScope>true</includeSystemScope>
	            </configuration>
	            <executions>
	                <execution>
	                    <goals>
	                        <goal>repackage</goal>
	                    </goals>
	                </execution>
	            </executions>
	        </plugin>
	   </plugins>
	</build>
</project>

接着新建包

  • com.learn.reptile.config 配置文件
  • com.learn.reptile.entity 实体类
  • com.learn.reptile.mapper 数据库操作接口
  • com.learn.reptile.utils 工具类
  • com.learn.reptile.web web层类

新建启动类 ReptileApplication

package com.learn.reptile;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication(scanBasePackages = "com.learn.reptile")
public class ReptileApplication {
	
	public static void main(String[] args) {
		SpringApplication.run(ReptileApplication.class, args);
	}

}

2、配置文件

在src/main/resources下新建配置文件application.yml,内容如下:

server:
  port: 8080
  
spring:
  application:
    name: reptile
  main:
    allow-bean-definition-overriding: true
  jackson:
    date-format: yyyy-MM-dd HH:mm
    time-zone: GMT+8
  servlet:
    multipart:
      max-file-size: 100MB
      max-request-size: 100MB
  redis:
    database: 1
    host: sincerely-host
    password: 85861367LiGzy
  datasource:
    username: test
    password: test
    url: jdbc:mysql://localhost:3306/reptile?useUnicode=true&useSSL=false&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowMultiQueries=true&allowPublicKeyRetrieval=true
    driver-class-name: com.mysql.cj.jdbc.Driver
    initial-size: 2
    min-idle: 1
    max-active: 20
    max-wait: 60000
    timeBetweenEvictionRunsMillis: 60000
    minEvictableIdleTimeMillis: 300000
    validationQuery: "select 'x'"
    testWhileIdle: true
    testOnBorrow: false
    testOnReturn: false
    poolPreparedStatements: true
    maxPoolPreparedStatementPerConnectionSize: 20
    filters: stat
    
mybatis-plus:
  global-config:
    id-type: 0
    db-column-underline: false
    refresh-mapper: true
  type-aliases-package: com.learn.reptile.entity.po
  mapper-locations: classpath:/mapper/*.xml
  configuration:
    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
    
    
logging:
  config: classpath:log4j2.xml

shiro:
  session-timeout: 1000000

log4j2.xml定义好日志级别、记录位置和格式

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN" monitorInterval="30">
    <Properties>
        <Property name="LOG_PATTERN">
            %d{yyyy-MM-dd HH:mm:ss.SSS} %5p %logger{36} --- [%15.15t] %l : %m%n
        </Property>
    </Properties>
    <Appenders>
        <Console name="Console" target="SYSTEM_OUT" follow="true">
            <PatternLayout pattern="${LOG_PATTERN}"/>
        </Console>
        <RollingRandomAccessFile name="DebugFile"
            fileName="logs/debug.log"
            filePattern="logs/debug-%d{yyyy-MM-dd}.log">
            <PatternLayout pattern="${LOG_PATTERN}"/>
            <Policies>
                <TimeBasedTriggeringPolicy interval="1" modulate="true" />
                <SizeBasedTriggeringPolicy size="10MB" />
            </Policies>
            <!-- Max 10 files will be created everyday -->
            <DefaultRolloverStrategy max="10">
                <Delete basePath="logs" maxDepth="10">
                    <!-- Delete all files older than 30 days -->
                    <IfLastModified age="30d" />
                </Delete>
            </DefaultRolloverStrategy>
        </RollingRandomAccessFile>
        <Async name="AsyncDebugFile">
            <AppenderRef ref="DebugFile" />
        </Async>
        
        <RollingRandomAccessFile name="InfoFile"
            fileName="logs/info.log"
            filePattern="logs/info-%d{yyyy-MM-dd}.log">
            <PatternLayout pattern="${LOG_PATTERN}"/>
            <Policies>
                <TimeBasedTriggeringPolicy interval="1" modulate="true" />
                <SizeBasedTriggeringPolicy size="10MB" />
            </Policies>
            <!-- Max 10 files will be created everyday -->
            <DefaultRolloverStrategy max="10">
                <Delete basePath="logs" maxDepth="10">
                    <!-- Delete all files older than 30 days -->
                    <IfLastModified age="30d" />
                </Delete>
            </DefaultRolloverStrategy>
        </RollingRandomAccessFile>
        <Async name="AsyncInfoFile">
            <AppenderRef ref="InfoFile" />
        </Async>
        
         <RollingRandomAccessFile name="WarnFile"
            fileName="logs/warn.log"
            filePattern="logs/warn-%d{yyyy-MM-dd}.log">
            <PatternLayout pattern="${LOG_PATTERN}"/>
            <Policies>
                <TimeBasedTriggeringPolicy interval="1" modulate="true" />
                <SizeBasedTriggeringPolicy size="10MB" />
            </Policies>
            <!-- Max 10 files will be created everyday -->
            <DefaultRolloverStrategy max="10">
                <Delete basePath="logs" maxDepth="10">
                    <!-- Delete all files older than 30 days -->
                    <IfLastModified age="30d" />
                </Delete>
            </DefaultRolloverStrategy>
        </RollingRandomAccessFile>
        <Async name="AsyncWarnFile">
            <AppenderRef ref="WarnFile" />
        </Async>
        
         <RollingRandomAccessFile name="ErrorFile"
            fileName="logs/error.log"
            filePattern="logs/error-%d{yyyy-MM-dd}.log">
            <PatternLayout pattern="${LOG_PATTERN}"/>
            <Policies>
                <TimeBasedTriggeringPolicy interval="1" modulate="true" />
                <SizeBasedTriggeringPolicy size="10MB" />
            </Policies>
            <!-- Max 10 files will be created everyday -->
            <DefaultRolloverStrategy max="10">
                <Delete basePath="logs" maxDepth="10">
                    <!-- Delete all files older than 30 days -->
                    <IfLastModified age="30d" />
                </Delete>
            </DefaultRolloverStrategy>
        </RollingRandomAccessFile>
        <Async name="AsyncErrorFile">
            <AppenderRef ref="ErrorFile" />
        </Async>
    </Appenders>
    
    <Loggers>
        <Logger name="com.learn.reptile" level="debug" additivity="false">
            <AppenderRef ref="Console" />
            <AppenderRef ref="AsyncDebugFile" />
        </Logger>
        <Root level="info">
            <AppenderRef ref="Console" />
            <AppenderRef ref="AsyncDebugFile" />
            <AppenderRef ref="AsyncInfoFile" />
            <AppenderRef ref="AsyncWarnFile" />
            <AppenderRef ref="AsyncErrorFile" />
        </Root>
    </Loggers>
</Configuration>

github代码:GitHub - guzhangyu/reptile-api: 商品正则采集器

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1961186.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

使用idea集成的springboot实现注册接口

跟黑马程序员学pringboot3vue3,代码都是黑马程序员视频里的代码 实战篇-03_注册接口_哔哩哔哩_bilibili 本文仅仅用于学习记录 开发用户接口 注册接口 开发流程&#xff1a;明确需求>>阅读接口文档>>思路分析>>开发>>测试 分析&#xff1a; 这个…

使用SDL库以及C++实现的简单的贪吃蛇:AI Fitten生成

简单使用AI代码生成器做了一个贪吃蛇游戏 设计的基本逻辑都是正确的&#xff0c;能流畅运行 免费准确率高&#xff0c;非常不错&#xff01;支持Visual Studio系列 Fitten&#xff1a;https://codewebchat.fittenlab.cn/ SDL 入门指南&#xff1a;安装配置https://blog.csdn.n…

高效数据抓取:Scrapy框架详解

一、Scrapy框架简介 Scrapy是一个为了爬取网站数据、提取结构性数据而编写的爬虫框架。它支持异步处理&#xff0c;能够快速抓取大量网页&#xff0c;并且易于扩展。Scrapy使用Twisted这个事件驱动的网络引擎&#xff0c;可以处理大量的并发请求&#xff0c;从而提高数据抓取的…

C语言分支结构作业

作业 输入你的身高和体重&#xff0c;测试你的健康状况。 计算bmi的值&#xff0c; bmi &#xff08;体重/身高的平方) 如果bmi 小于18.5&#xff0c;则显示“偏瘦&#xff0c;注意加强营养” 如果bmi 在18.5和23.9之间&#xff0c;则显示“体重指数良好&#xff0c;注意保持…

【全栈实战】大模型自学:从入门到实战打怪升级,20W字总结(二)

&#x1f60a;你好&#xff0c;我是小航&#xff0c;一个正在变秃、变强的文艺倾年。 &#x1f514;本栏讲解【全栈实战】大模型自学&#xff1a;从入门到实战打怪升级。 &#x1f514;专栏持续更新&#xff0c;适合人群&#xff1a;本科生、研究生、大模型爱好者&#xff0c;期…

基于单片机的电梯控制系统的设计

摘 要: 本文提出了一种基于单片机的电梯控制系统设计 。 设计以单片机为核心&#xff0c;通过使用和设计新型先进的硬件和控制程序来模拟和控制整个电梯的运行&#xff0c;在使用过程中具有成本低廉、 维护方便、 运行稳定 、 易于操作 、 安全系数高等优点 。 主要设计思路是…

聚焦全局应用可用性的提升策略,详解GLSB是什么

伴随互联网的快速发展和全球化趋势的深入&#xff0c;企业对网络应用的需求日渐增长。为满足全球范围内用户大量的访问需求&#xff0c;同时解决容灾、用户就近访问以及全球应用交付等问题&#xff0c;GLSB&#xff08;全局负载均衡&#xff09;也因此应运而生。那么GLSB是什么…

Axure RP:打造动态交互的大屏可视化设计利器

Axure大屏可视化是指使用Axure RP这款原型设计工具来创建具有视觉冲击力和数据展示功能的大屏幕界面。Axure以其强大的交互设计和丰富的组件库&#xff0c;成为了实现大屏可视化的重要工具之一。以下是对Axure大屏可视化的详细阐述&#xff1a; 一、Axure在大屏可视化中的优势 …

​易能医药董事长易跃能博士荣获“湖湘药学领航奖”

近日&#xff0c;湖南省药学会主办的“湖南省药学会70周年庆典暨第六届湖南药学大会”在湖南长沙隆重召开。易能医药董事长易跃能博士荣获由湖南省药学会颁发的“湖湘药学领航奖”。此次“湖湘药学领航奖”由湖南药学大会学术委员会组织评选&#xff0c;湖南省全省仅有八个名额…

六、3 PWM 舵机代码

目录 1、通道选择 2、参数计算 3、代码部分 1、通道选择 PA1对应通道2 注意&#xff1a;同一个定时器不同通道输出PWM的特点 同一个定时器的不同通道输出的PWM&#xff0c;频率相同&#xff08;因为它们共用一个计数器&#xff09;&#xff0c;占空比可以各自设定&#xff…

Kubernetes 学习记录

https://note.youdao.com/ynoteshare/index.html?idbc7bee305611b52d6900ba209a92bd4d&typenote&_time1694072007342 概览 K8S官网文档&#xff1a;https://kubernetes.io/zh/docs/home/ K8S 是Kubernetes的全称&#xff0c;源于希腊语&#xff0c;意为“舵手”或“…

ITSS:IT服务工程师

证书亮点&#xff1a;适中的费用、较低的难度、广泛的应用范围以及专业的运维认证。 总体评价&#xff1a;性价比良好&#xff01; 证书名称&#xff1a;ITSS服务工程师 证书有效期&#xff1a;持续3年 培训要求&#xff1a;必须参加培训&#xff0c;否则将无法参与考试 发…

Aboboo一些操作

常用快捷键⌨ 快捷键/操作方式 功能 鼠标中键/Esc 进入/退出全屏 空格/Tab 暂停/恢复播放 左/右箭头 快退/快进 Ctrl-左/右箭头 30秒快退/快进 Alt-左/右箭头 60秒快退/快进 Ctrl-Alt-左/右箭头 播放速率调节 PageUp/PageDown 上一句/下一句 上下箭头/滚轮 …

WSL配置镜像网络使用本地端口调试Linux程序

一、安装WSL 二、配置WSL为镜像 在C:\Users\XXUser目录下添加.wslconfig文件 [wsl2] networkingModemirrored # 开启镜像网络 dnsTunnelingtrue # 开启 DNS Tunneling firewalltrue # 开启 Windows 防火墙 autoProxytrue # 开启自动同步代理重启WSL wsl --shutdown wsl三、…

计算机毕业设计选题推荐-音乐播放系统-Java/Python项目实战

✨作者主页&#xff1a;IT毕设梦工厂✨ 个人简介&#xff1a;曾从事计算机专业培训教学&#xff0c;擅长Java、Python、微信小程序、Golang、安卓Android等项目实战。接项目定制开发、代码讲解、答辩教学、文档编写、降重等。 ☑文末获取源码☑ 精彩专栏推荐⬇⬇⬇ Java项目 Py…

计算机网络04

文章目录 IP 基本认识**IP 地址的基础知识****IP 地址的分类**无分类地址 CIDR公有 IP 地址与私有 IP 地址IP 地址与路由控制IP 分片与重组IPv6 基本认识IPv4 首部与 IPv6 首部 IP 协议相关技术DNS 域名解析ARP 与 RARP 协议DHCP 动态获取 IP 地址NAT 网络地址转换ICMP 互联网控…

NACOS保姆笔记(5)——Nacos的集群教程

前面我们介绍过: NACOS保姆笔记(1)——NACOS的安装和启动NACOS保姆笔记(2)——Spring Cloud Alibaba Nacos服务注册与发现以及负载均衡NACOS保姆笔记(3)——Spring Cloud Alibaba Nacos配置中心NACOS保姆笔记(4)——Spring Cloud Alibaba Nacos鉴权本篇主要介绍下Na…

5种IO模型简述

文章目录 前言什么是IO模型&#xff1f;阻塞IO非阻塞IO多路复用IO信号驱动IO异步IO 结语 前言 最近学netty&#xff0c;当然无法避免IO模型这部分知识。 我尽量用最简洁的语言来讲清楚这个东西。 什么是IO模型&#xff1f; 既然最近学netty&#xff0c;就拿它来举例子。 比如…

ITPUB专访 | 张宏波:一场关于编程语言速度与效率的深度对话

ITPUB专访 | 张宏波&#xff1a;一场关于编程语言速度与效率的深度对 随着 AI 大语言模型&#xff08;LLM&#xff09;不断突破和开源社区活跃程度达到前所未有的高度&#xff0c;以 OpenAI 的 GPT-4、Meta-LLaMA 等为代表的重量级产品和服务相继发布&#xff0c;AI 技术的蓬勃…

视频VIP收费会员播放帝国CMS模板HTML5自适应手机多种运营模式

采用帝国CMS最新版核心制作&#xff0c;自适应响应式手机平板浏览&#xff0c;手机浏览器非常舒服哦&#xff01;多种运营模式。用户中心逻辑和页面&#xff0c;都已经制作完整&#xff0c;可以搭建后稍微修改即可使用&#xff01; 模板特点&#xff1a; 支持多集和单集播放&…