# 简介
**最新使用Maven搭建springMVC+spring+mybatis(SSM)。
**实现基于mahout的系统过滤推荐
**博客:https://blog.csdn.net/weixin_40017996/article/details/108961212
# 环境
* Windows 10
* MySql 5.7
* JDK 1.8
* Maven 3.3.9
* IDEA 2018
# 技术选型
名称 | 描述 | 版本号 | 网址
--- | --- | --- | ---
Spring MVC| MVC框架 | 4.3.11.RELEASE | [https://docs.spring.io/spring/docs/current/spring-framework-reference/web.html#mvc](https://docs.spring.io/spring/docs/current/spring-framework-reference/web.html#mvc)
Spring Framework | 容器 | 4.3.10.RELEASE | [http://projects.spring.io/spring-framework/](http://projects.spring.io/spring-framework/)
MyBatis| ORM/持久层框架 | 3.4.5 | [http://www.mybatis.org/mybatis-3/zh/index.html](http://www.mybatis.org/mybatis-3/zh/index.html)
AspectJ| 面向切面的框架 | 1.8.10 | [http://www.eclipse.org/aspectj/](http://www.eclipse.org/aspectj/)
Druid| 数据库连接池 | 1.1.3 | [https://github.com/alibaba/druid](https://github.com/alibaba/druid)
Jackson| json解析器 | 2.9.1 | [https://github.com/FasterXML/jackson](https://github.com/FasterXML/jackson)
Logback| 日志组件 | 1.2.3 | [https://logback.qos.ch](https://logback.qos.ch)
Maven| 项目构建管理 | 3.3.9 | [http://maven.apache.org/](http://maven.apache.org/)
# 搭建步骤
## 一、创建Maven项目
略
## 二、配置web.xml文件
```xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
id="WebApp_ID" version="3.1">
<display-name>ssm</display-name>
<!-- 过滤器解决中文乱码问题、强制编码 UTF-8 -->
<filter>
<filter-name>characterEncodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceRequestEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>characterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- 配置 springMVC 基本配置 -->
<servlet>
<servlet-name>springMVC</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring-mvc.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springMVC</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<!-- 配置 spring 监听器 -->
<!-- needed for ContextLoaderListener -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<!-- Bootstraps the root web application context before servlet initialization -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- 配置欢迎页 -->
<welcome-file-list>
<welcome-file>views/index.jsp</welcome-file>
</welcome-file-list>
</web-app>
```
## 四、在src/main/resources下创建spring配置文件
##### 创建applicationContext.xml配置如下
```xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.3.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd">
<!-- 自动扫描指定目录,将控制器加载到bean -->
<context:component-scan base-package="com.frame" />
<!-- 配置 druid 数据源 -->
<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close">
<!-- 基本属性 url、user、password、driverClass -->
<property name="username" value="root" />
<property name="password" value="root" />
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://192.168.0.200:3306/test?useUnicode=true&characterEncoding=utf8&useSSL=false" />
</bean>
<!-- 配置 sessionFactory -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="mapperLocations">
<list>
<value>classpath:com/frame/**/*Mapper.xml</value>
<value>classpath:mybatis/**/*Mapper.xml</value>
</list>
</property>
</bean>
<!-- 配置 sqlSessionTemplate 持久化模板 -->
<bean id="sqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate">
<constructor-arg ref="sqlSessionFactory" />
</bean>
<!-- 配置事物管理器 -->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<!-- 配置事物传播行为 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="get*" read-only="true" />
<tx:method name="find*" read-only="true" />
<tx:method name="select*" read-only="true" />
<tx:method name="*" propagation="REQUIRED" />
</tx:attributes>
</tx:advice>
<!-- 配置事物切入点 -->
<aop:config>
<aop:pointcut expression="execution(* com.frame.service.*.*(..))" id="pointCut" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="pointCut" />
</aop:config>
<!-- 开始声明式事务(事物注解) -->
<tx:annotation-driven transaction-manager="transactionManager" />
</beans>
```
##### 创建spring-mvc.xml配置如下
```xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd">
<!-- 自动将控制器加载到bean -->
<context:component-scan base-package="com.frame.controller" />
<!-- 配置视图解析器 -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/views/" />
<property name="suffix" value=".jsp" />
<!-- 可为空,方便实现自已的依据扩展名来选择视图解释类的逻辑 -->
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
</bean>
<!-- 返回json 需导入 jackson-annotations.jar,jackson-core.jar,jackson-databind.jar -->
<!-- 通过处理器映射DefaultAnnotationHandlerMapping来开启支持@Controller注解 -->
<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping" />
<!-- 通过处理器适配器AnnotationMethodHandlerAdapter来开启支持@RequestMapping注解 -->
<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
<property name="messageConverters">
<list>
<!-- 配置返回字符串编码 -->
<bean
class="org.springframework.http.converter.StringHttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>text/html; ch
没有合适的资源?快使用搜索试试~ 我知道了~
mahou/协同过滤+源代码+文档说明
共55个文件
java:19个
xml:8个
js:6个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 143 浏览量
2024-04-24
10:15:27
上传
评论
收藏 7.24MB ZIP 举报
温馨提示
- 不懂运行,下载完可以私聊问,可远程教学 该资源内项目源码是个人的毕设,代码都测试ok,都是运行成功后才上传资源,答辩评审平均分达到96分,放心下载使用! <项目介绍> 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用! 2、本项目适合计算机相关专业(如计科、人工智能、通信工程、自动化、电子信息等)的在校学生、老师或者企业员工下载学习,也适合小白学习进阶,当然也可作为毕设项目、课程设计、作业、项目初期立项演示等。 3、如果基础还行,也可在此代码基础上进行修改,以实现其他功能,也可用于毕设、课设、作业等。 下载后请首先打开README.md文件(如有),仅供学习参考, 切勿用于商业用途。 --------
资源推荐
资源详情
资源评论
收起资源包目录
ssm-master.zip (55个子文件)
ssm-master
.classpath 1KB
slope1.png 340KB
ssm.iml 8KB
.settings
org.eclipse.wst.jsdt.ui.superType.name 6B
org.eclipse.jdt.core.prefs 422B
.jsdtscope 626B
org.eclipse.wst.validation.prefs 48B
org.eclipse.wst.common.component 655B
org.eclipse.wst.common.project.facet.core.xml 245B
org.eclipse.wst.jsdt.ui.superType.container 49B
org.eclipse.m2e.core.prefs 86B
pom.xml 6KB
user1.png 331KB
src
main
resources
shuju
README 5KB
users.dat 131KB
ratings.dat 23.45MB
movies.dat 167KB
spring-mvc.xml 2KB
applicationContext.xml 3KB
mybatis
DemoMapper.xml 292B
MovieInfoMapper.xml 2KB
java
com
frame
mapper
DemoMapper.java 139B
MovieInfoMapper.java 254B
controller
UserItemController.java 2KB
DemoController.java 1KB
service
DemoService.java 135B
impl
MovieInfoServiceImpl.java 2KB
DemoServiceImpl.java 870B
MovieInfoService.java 406B
recommender
UserItem.java 3KB
entity
MovieInfo.java 1KB
Rating.java 733B
Movie.java 928B
Test.java 348B
util
ListToString.java 478B
MyDataModel.java 1KB
DButil.java 719B
Rateing.java 3KB
Movies.java 3KB
StringUtil.java 536B
webapp
WEB-INF
web.xml 2KB
views
index.jsp 1KB
image
p2969.jpg 414KB
js
jquery.backstretch.js 12KB
jquery-1.11.1.js 276KB
jquery.backstretch.min.js 4KB
jquery-1.11.1.min.js 94KB
placeholder.js 120B
scripts.js 709B
recommendResult.jsp 2KB
hello.jsp 359B
.idea
vcs.xml 180B
item1.png 319KB
.project 1KB
README.md 11KB
共 55 条
- 1
资源评论
机器学习的喵
- 粉丝: 519
- 资源: 1268
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功