赞
踩
slf4j-log4j12
org.apache.maven.plugins
maven-compiler-plugin
${maven.compiler.plugin.version}
${java.version}${java.version}
${project.build.sourceEncoding}
org.apache.maven.plugins
maven-resources-plugin
${maven.resources.plugin.version}
${project.build.sourceEncoding}
org.springframework.boot
spring-boot-maven-plugin
true
true
repackage
public
aliyun nexus
http://maven.aliyun.com/nexus/content/groups/public/
true
public
aliyun nexus
http://maven.aliyun.com/nexus/content/groups/public/
true
false
配置mysql数据源,druid数据库连接池以及MyBatis的mapper文件的位置。Spring Boot 基础就不介绍了,最全教程和示例源码推荐看这里:https://github.com/javastacks/spring-boot-best-practice
# mysql数据源配置
spring.datasource.name=mysql
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://192.168.0.63:3306/gjhzjl?useUnicode=true&characterEncoding=utf8&useSSL=false&allowMultiQueries=true
spring.datasource.username=root
spring.datasource.password=root
# druid数据库连接池配置
spring.datasource.druid.initial-size=5
spring.datasource.druid.min-idle=5
spring.datasource.druid.max-active=10
spring.datasource.druid.max-wait=60000
spring.datasource.druid.validation-query=SELECT 1 FROM DUAL
spring.datasource.druid.test-on-borrow=false
spring.datasource.druid.test-on-return=false
spring.datasource.druid.test-while-idle=true
spring.datasource.druid.time-between-eviction-runs-millis=60000
spring.datasource.druid.min-evictable-idle-time-millis=300000
spring.datasource.druid.max-evictable-idle-time-millis=600000
# mybatis配置
mybatis.mapperLocations=classpath:mapper/**/*.xml
CREATE TABLE cms_content
(
contentId
varchar(40) NOT NULL COMMENT ‘内容ID’,
title
varchar(150) NOT NULL COMMENT ‘标题’,
content
longtext COMMENT ‘文章内容’,
releaseDate
datetime NOT NULL COMMENT ‘发布日期’,
PRIMARY KEY (contentId
)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT=‘CMS内容表’;
import java.util.Date;
public class CmsContentPO {
private String contentId;
private String title;
private String content;
private Date releaseDate;
public String getContentId() {
return contentId;
}
public void setContentId(String contentId) {
this.contentId = contentId;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public Date getReleaseDate() {
return releaseDate;
}
public void setReleaseDate(Date releaseDate) {
this.releaseDate = releaseDate;
}
}
public interface CrawlerMapper {
int addCmsContent(CmsContentPO record);
}
insert into cms_content (contentId,
title,
releaseDate,
content)
values (#{contentId,jdbcType=VARCHAR},
#{title,jdbcType=VARCHAR},
#{releaseDate,jdbcType=TIMESTAMP},
#{content,jdbcType=LONGVARCHAR})
主要用于解析爬取到的XXX html页面。
点击关注公众号,Java干货****及时送达
@Component
public class XXXPageProcessor implements PageProcessor {
private Site site = Site.me().setRetryTimes(3).setSleepTime(1000);
@Override
public void process(Page page) {
page.addTargetRequests(page.getHtml().links().regex(“https://www\.xxx\.com/question/\d+/answer/\d+.*”).all());
page.putField(“title”, page.getHtml().xpath(“//h1[@class=‘QuestionHeader-title’]/text()”).toString());
page.putField(“answer”, page.getHtml().xpath(“//div[@class=‘QuestionAnswer-content’]/tidyText()”).toString());
if (page.getResultItems().get(“title”) == null) {
// 如果是列表页,跳过此页,pipeline不进行后续处理
page.setSkip(true);
}
}
@Override
public Site getSite() {
return site;
}
}
主要用于将XXX html页面解析出的数据存储到mysql数据库。另外,MySQL 系列面试题和答案全部整理好了,微信搜索Java技术栈,在后台发送:面试,可以在线阅读。
@Component
public class XXXPipeline implements Pipeline {
private static final Logger LOGGER = LoggerFactory.getLogger(XXXPipeline.class);
@Autowired
private CrawlerMapper crawlerMapper;
public void process(ResultItems resultItems, Task task) {
String title = resultItems.get(“title”);
String answer = resultItems.get(“answer”);
CmsContentPO contentPO = new CmsContentPO();
contentPO.setContentId(UUID.randomUUID().toString());
contentPO.setTitle(title);
contentPO.setReleaseDate(new Date());
contentPO.setContent(answer);
try {
boolean success = crawlerMapper.addCmsContent(contentPO) > 0;
LOGGER.info(“保存文章成功:{}”, title);
} catch (Exception ex) {
LOGGER.error(“保存文章失败”, ex);
}
}
}
@Component
public class XXXTask {
private static final Logger LOGGER = LoggerFactory.getLogger(XXXPipeline.class);
@Autowired
private XXXPipeline XXXPipeline;
@Autowired
private XXXPageProcessor xxxPageProcessor;
private ScheduledExecutorService timer = Executors.newSingleThreadScheduledExecutor();
public void crawl() {
// 定时任务,每10分钟爬取一次
timer.scheduleWithFixedDelay(() -> {
Thread.currentThread().setName(“xxxCrawlerThread”);
try {
Spider.create(xxxPageProcessor)
// 从https://www.xxx.com/explore开始抓
.addUrl(“https://www.xxx.com/explore”)
// 抓取到的数据存数据库
.addPipeline(xxxPipeline)
// 开启2个线程抓取
.thread(2)
// 异步启动爬虫
.start();
} catch (Exception ex) {
LOGGER.error(“定时抓取数据线程执行异常”, ex);
}
}, 0, 10, TimeUnit.MINUTES);
}
自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。
深知大多数前端工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!
因此收集整理了一份《2024年Web前端开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上前端开发知识点,真正体系化!
由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!
如果你觉得这些内容对你有帮助,可以扫码获取!!(备注:前端)
面试题千万不要死记,一定要自己理解,用自己的方式表达出来,在这里预祝各位成功拿下自己心仪的offer。
需要完整面试题的朋友可以点击蓝色字体获取
d2z8-1712955594259)]
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上前端开发知识点,真正体系化!
[外链图片转存中…(img-CPUC5kud-1712955594260)]
由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!
如果你觉得这些内容对你有帮助,可以扫码获取!!(备注:前端)
面试题千万不要死记,一定要自己理解,用自己的方式表达出来,在这里预祝各位成功拿下自己心仪的offer。
需要完整面试题的朋友可以点击蓝色字体获取
[外链图片转存中…(img-ZKOBCh4Y-1712955594260)]
[外链图片转存中…(img-PE4cpFje-1712955594260)]
[外链图片转存中…(img-MgFSMmcI-1712955594261)]
[外链图片转存中…(img-uOKeRQIa-1712955594261)]
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。