图表显示日志离线信息

2020-05-14  本文已影响0人  那山的狐狸

关注公众号:分享电脑学习

回复"百度云盘" 可以免费获取所有学习文档的代码(不定期更新)

云盘目录说明:

tools目录是安装包

res 目录是每一个课件对应的代码和资源等

doc 目录是一些第三方的文档工具

承接上一篇文档《Hive分析统计hour信息

准备数据库lx_data

创建pom项目

配置pom

3.2.1.RELEASE3.1.11.2.17junitjunit3.8.1testjavax.servletservlet-api2.5providedorg.springframeworkspring-core${spring.version}org.springframeworkspring-web${spring.version}org.springframeworkspring-oxm${spring.version}org.springframeworkspring-tx${spring.version}org.springframeworkspring-jdbc${spring.version}org.springframeworkspring-webmvc${spring.version}org.springframeworkspring-aop${spring.version}org.springframeworkspring-context-support${spring.version}org.springframeworkspring-test${spring.version}org.mybatismybatis${mybatis.version}org.mybatismybatis-spring1.2.2mysqlmysql-connector-java5.1.18com.mchangec3p00.9.5log4jlog4j${log4j.version}<!-- spring如果需要返回json格式的数据,那么必须引入下面两个包 -->org.codehaus.jacksonjackson-core-asl1.9.13org.codehaus.jacksonjackson-mapper-asl1.9.13

创建并配置jdbc.properties

# local

jdbc.driverClassName=com.mysql.jdbc.Driver

jdbc.url=jdbc:mysql://localhost:3306/lx_data?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true

jdbc.username=root

jdbc.password=

jdbc.minPoolSize=2

jdbc.maxPoolSize=20

jdbc.acquireIncrement=2

jdbc.initialPoolSize=3

jdbc.testConnectionOnCheckout=false

jdbc.idleConnectionTestPeriod=3600

jdbc.maxIdleTime=3600

创建并配置log4j.properties

log4j.rootCategory=info,stdout,fileout

### stdout

log4j.appender.stdout=org.apache.log4j.ConsoleAppender

log4j.appender.stdout.layout=org.apache.log4j.PatternLayout

log4j.appender.stdout.layout.ConversionPattern=%d{MM-dd-HH\:mm\:ss} - lx_dataapi - [%t] %-5p [%C\:%L]%x %m%n

### fileout

log4j.appender.fileout=org.apache.log4j.DailyRollingFileAppender

log4j.appender.fileout.File=${catalina.base}/logs/dataapi.log

log4j.appender.fileout.layout=org.apache.log4j.PatternLayout

log4j.appender.fileout.layout.ConversionPattern=%d{MM-dd-HH\:mm\:ss} - lx_dataapi - [%t] %-5p [%C\:%L]%x %m%n

log4j.appender.fileout.DatePattern='.'yyyy-MM-dd

### print the mybatis execute sql

log4j.logger.org.apache.ibatis=DEBUG

log4j.logger.java.sql=DEBUG

创建并配置 ae-mvc.xml

<?xml version="1.0"encoding="UTF-8"?>

http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans-3.0.xsd

http://www.springframework.org/schema/context

http://www.springframework.org/schema/context/spring-context-3.0.xsd

http://www.springframework.org/schema/aop

http://www.springframework.org/schema/aop/spring-aop-3.0.xsd

http://www.springframework.org/schema/tx

http://www.springframework.org/schema/tx/spring-tx-3.0.xsd

http://www.springframework.org/schema/mvc

http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">Spring-web MVC配置<!-- 这两个类用来启动基于Spring MVC的注解功能,将控制器与方法映射加入到容器中 --><!-- 对所有类进行扫描,以完成Bean创建和自动依赖注入的功能 --><!-- 添加静态资源访问 -->

创建并配置 ae-beans.xml

<?xml version="1.0"encoding="UTF-8"?>

http://www.springframework.org/schema/beans/spring-beans.xsd

http://www.springframework.org/schema/aop

http://www.springframework.org/schema/aop/spring-aop-3.0.xsd

http://www.springframework.org/schema/cache

http://www.springframework.org/schema/cache/spring-cache.xsd

http://www.springframework.org/schema/context

http://www.springframework.org/schema/context/spring-context-3.0.xsd

http://www.springframework.org/schema/mvc

http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd

http://www.springframework.org/schema/util

http://www.springframework.org/schema/util/spring-util-3.0.xsd

"default-autowire="byName"><!-- 创建jdbc -->classpath:jdbc.properties<!-- ae相关配置信息 -->classpath*:com/wzy/ae/**/*Mapper.xml<!-- 具体service bean --><!-- 具体service bean结束 --><!-- bucket.metric 对应的计算类bean --><!-- bucket.metric 对应的计算类bean结束 --><!-- dao相关bean --><!-- dao相关bean结束 --><!-- 共用service bean --><!-- 共用service bean结束 -->创建并配置aeConfigContext.xml

<?xml version="1.0"encoding="UTF-8"?>

http://www.springframework.org/schema/beans/spring-beans-3.0.xsd

http://www.springframework.org/schema/aop

http://www.springframework.org/schema/aop/spring-aop-3.0.xsd

http://www.springframework.org/schema/cache

http://www.springframework.org/schema/cache/spring-cache.xsd

http://www.springframework.org/schema/context

http://www.springframework.org/schema/context/spring-context-3.0.xsd

http://www.springframework.org/schema/mvc

http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd

http://www.springframework.org/schema/util

http://www.springframework.org/schema/util/spring-util-3.0.xsd

"><!-- bucket metric 参数,定义的是从mysql获取的列名 --><!-- bucket metric 返回value参数 结束 --><!-- bucket metric query id 参数 --><!-- bucket metric query id 参数结束 --><!-- bucket metric 参数 -->orderssuccess_ordersrefund_ordersorder_amountrevenue_amountrefund_amounttotal_revenue_amounttotal_refund_amounttimesuvvisitbounce_numberview_depth_of_userview_depth_of_sessionuvvisitbounce_numberactive_userstotal_usersnew_usersactive_memberstotal_membersnew_memberssessionssessions_lengthpvactive_usersactive_user_ratetotal_usersnew_usersnew_user_ratenew_user_speed_rateactive_user_speed_ratetotal_user_speed_rateactive_membersactive_member_ratetotal_membersnew_membersnew_member_ratenew_member_speed_rateactive_member_speed_ratetotal_member_speed_ratesessionssessions_lengthhourly_sessionshourly_sessions_lengthhourly_active_user<!-- bucket metric 参数结束--><!-- bucket group 参数-->day<!-- <value>week</value>

<value>month</value>

<value>season</value>

<value>year</value> -->platformbrowserbrowser_versioncountryprovincecityinboundcategoryactioncurrency_typepayment_type<!-- bucket group 参数-->

创建包结构

完成web.xml的内容

环境完成后

完成common包中

创建AEConstants

完成model包中的代码

完成util包中的代码

完成calculate包中的代码

完成dao包中的代码

完成service包下面代码

最后再完成controller中的代码

准备页面

运行,访问http://localhost:8080/dataapi/analyse/index.html

出现错误,将jdk版本降下来就行了

spring 3.2不支持1.8编译环境,解决办法就是降为1.7编译环境

spring官网说了,要使用java8,只支持spring 4.X以上版本,而spring的使用最低java要求java5及以上

再次运行就可以了,因为数据是旧的注意日期的选择

代码和数据库已经上传,直接下载就可以运行了

上一篇下一篇

猜你喜欢

热点阅读