├── .gitignore
├── .mvn
└── wrapper
│ ├── maven-wrapper.jar
│ └── maven-wrapper.properties
├── LICENSE
├── README.md
├── README_IMG
├── 系统功能模块.png
└── 项目打成jar包.png
├── mrs.sql
├── mvnw
├── mvnw.cmd
├── pom.xml
└── src
├── main
├── java
│ └── cn
│ │ └── zjw
│ │ └── mrs
│ │ ├── MovieRecommendationSystemApplication.java
│ │ ├── config
│ │ ├── CorsConfig.java
│ │ ├── ExecutorConfig.java
│ │ ├── MySqlDataModelConfig.java
│ │ ├── MybatisPlusConfig.java
│ │ ├── OssClientConfig.java
│ │ ├── RedisConfig.java
│ │ └── SecurityConfig.java
│ │ ├── controller
│ │ ├── AuthController.java
│ │ ├── CommentController.java
│ │ ├── MovieController.java
│ │ ├── RecommendationController.java
│ │ ├── UserController.java
│ │ └── UserPreferenceController.java
│ │ ├── entity
│ │ ├── Comment.java
│ │ ├── LoginUser.java
│ │ ├── Movie.java
│ │ ├── MovieFeature.java
│ │ ├── MovieRegion.java
│ │ ├── MovieType.java
│ │ ├── Preference.java
│ │ ├── Recommendation.java
│ │ ├── RegionLike.java
│ │ ├── Result.java
│ │ ├── SameLikes.java
│ │ ├── TypeLike.java
│ │ ├── User.java
│ │ └── UserLike.java
│ │ ├── enums
│ │ ├── HttpCodeEnum.java
│ │ ├── LikedStatusEnum.java
│ │ ├── RecommendationTypeEnum.java
│ │ ├── RegionEnum.java
│ │ ├── SexEnum.java
│ │ └── TypeEnum.java
│ │ ├── filter
│ │ └── JwtAuthenticationTokenFilter.java
│ │ ├── handler
│ │ ├── AccessDeniedHandlerImpl.java
│ │ └── AuthenticationEntryPointImpl.java
│ │ ├── mapper
│ │ ├── CommentMapper.java
│ │ ├── MovieFeatureMapper.java
│ │ ├── MovieMapper.java
│ │ ├── MovieRegionMapper.java
│ │ ├── MovieTypeMapper.java
│ │ ├── RecommendationMapper.java
│ │ ├── RegionLikeMapper.java
│ │ ├── SameLikesMapper.java
│ │ ├── TypeLikeMapper.java
│ │ ├── UserLikeMapper.java
│ │ └── UserMapper.java
│ │ ├── service
│ │ ├── AuthService.java
│ │ ├── CommentService.java
│ │ ├── MovieFeatureService.java
│ │ ├── MovieRegionService.java
│ │ ├── MovieService.java
│ │ ├── MovieTypeService.java
│ │ ├── OssService.java
│ │ ├── RecommendationService.java
│ │ ├── RegionLikeService.java
│ │ ├── SameLikesService.java
│ │ ├── TypeLikeService.java
│ │ ├── UserLikeRedisService.java
│ │ ├── UserLikeService.java
│ │ ├── UserService.java
│ │ └── impl
│ │ │ ├── AuthServiceImpl.java
│ │ │ ├── CommentServiceImpl.java
│ │ │ ├── MovieFeatureServiceImpl.java
│ │ │ ├── MovieRegionServiceImpl.java
│ │ │ ├── MovieServiceImpl.java
│ │ │ ├── MovieTypeServiceImpl.java
│ │ │ ├── OssServiceImpl.java
│ │ │ ├── RecommendationServiceImpl.java
│ │ │ ├── RegionLikeServiceImpl.java
│ │ │ ├── SameLikesServiceImpl.java
│ │ │ ├── TypeLikeServiceImpl.java
│ │ │ ├── UserDetailsServiceImpl.java
│ │ │ ├── UserLikeRedisServiceImpl.java
│ │ │ ├── UserLikeServiceImpl.java
│ │ │ └── UserServiceImpl.java
│ │ ├── utils
│ │ ├── Base64DecodedMultipartFile.java
│ │ ├── FastJsonRedisSerializer.java
│ │ ├── FileUtil.java
│ │ ├── JwtUtil.java
│ │ ├── MailUtil.java
│ │ ├── MyDataModel.java
│ │ ├── PicUrlUtil.java
│ │ ├── RecommendationUtil.java
│ │ ├── RedisCache.java
│ │ ├── RedisKeyUtil.java
│ │ └── WebUtils.java
│ │ └── vo
│ │ ├── comment
│ │ ├── CommentMovieVo.java
│ │ └── CommentStripVo.java
│ │ ├── movie
│ │ ├── MovieCardVo.java
│ │ ├── MovieStripVo.java
│ │ ├── RecommendedMovieVo.java
│ │ ├── ReviewedMovieStripVo.java
│ │ └── relation
│ │ │ ├── CategoryVo.java
│ │ │ ├── LinkVo.java
│ │ │ └── NodeVo.java
│ │ └── user
│ │ ├── LoginUserVo.java
│ │ └── UserInfoVo.java
└── resources
│ ├── application.yml
│ ├── mapper
│ ├── CommentMapper.xml
│ ├── MovieFeatureMapper.xml
│ ├── MovieMapper.xml
│ ├── MovieRegionMapper.xml
│ ├── MovieTypeMapper.xml
│ ├── RecommendationMapper.xml
│ ├── RegionLikeMapper.xml
│ ├── SameLikesMapper.xml
│ ├── TypeLikeMapper.xml
│ ├── UserLikeMapper.xml
│ └── UserMapper.xml
│ └── static
│ └── assets
│ └── StopWords.txt
└── test
└── java
└── cn
└── zjw
└── mrs
├── CommentTest.java
├── JiebaTest.java
├── MailTest.java
├── MovieRecommendationSystemApplicationTests.java
├── MovieTest.java
├── RecommendTest.java
├── RedisTest.java
├── UserLikeTest.java
└── UserMapperTest.java
/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 | !**/src/main/**/target/
5 | !**/src/test/**/target/
6 |
7 | ### STS ###
8 | .apt_generated
9 | .classpath
10 | .factorypath
11 | .project
12 | .settings
13 | .springBeans
14 | .sts4-cache
15 |
16 | ### IntelliJ IDEA ###
17 | .idea
18 | *.iws
19 | *.iml
20 | *.ipr
21 |
22 | ### NetBeans ###
23 | /nbproject/private/
24 | /nbbuild/
25 | /dist/
26 | /nbdist/
27 | /.nb-gradle/
28 | build/
29 | !**/src/main/**/build/
30 | !**/src/test/**/build/
31 |
32 | ### VS Code ###
33 | .vscode/
34 |
--------------------------------------------------------------------------------
/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/junweizeng/movie_recommendation_system_server/ef700cde27920be226f10d5e453ef154ea685396/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip
2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
3 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 Junwei Zeng
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # 电影推荐系统(后端)
2 |
3 | ## Star History
4 |
5 | [](https://www.star-history.com/#junweizeng/movie_recommendation_system_server&Date)
6 |
7 | ## 前言
8 |
9 | 总项目名称:`电影推荐系统`
10 |
11 | 项目采用`前后端分离`:
12 |
13 | 1. 前端:
14 | - 仓库地址:[movie_recommendation_system_vue](https://github.com/jun-wei-zeng/movie_recommendation_system_vue)
15 | - 技术栈:`Vue3` + `Element Plus` + `axios`等
16 | 2. 后端:
17 | - 仓库地址:[movie_recommendation_system_server](https://github.com/jun-wei-zeng/movie_recommendation_system_server)
18 | - 技术栈:`Spring Boot` + `Spring Security` + `Redis` + `MyBatis-Plus`等
19 | 3. 数据爬虫:
20 | - 简介:爬取项目所需的电影基本信息数据和用户评价数据等并存储。
21 | - 仓库地址:[douban_movie_spider_mrs](https://github.com/jun-wei-zeng/douban_movie_spider_mrs/tree/master)
22 | - 技术栈:`requests` + `lxml`
23 |
24 | 系统功能模块总览:
25 |
26 | 
27 |
28 | ## 1. 项目打包部署
29 |
30 | ### 1.1 项目打包
31 |
32 | IDEA右边栏中选择`Maven` → 按住`Ctrl` → 选择`Lifecycle`下的`clean`和`package` → 点击上方的`绿色运行按钮` → 等待项目打包成jar包 → 打包好的jar包会在项目的`target`目录中
33 |
34 | 
35 |
36 | ### 1.2 项目部署
37 |
38 | 1. 将打包好的`项目jar包`上传到自己的服务器上。
39 |
40 | 2. 通过以下命令时项目在服务器后台运行,并且输出日志到`out.txt`文件(可修改):
41 |
42 | >nohup java -jar 项目名.jar >out.txt &
43 |
44 | ## 2. 后端功能实现
45 |
46 | 1. 用户登录、注册、个人信息修改等接口实现。
47 | 2. 基于内容推荐和基于用户协同过滤推荐等推荐算法实现,整合两种算法实现混合式推荐,并解决冷启动问题。
48 | 3. 查询各种电影信息接口实现(如电影搜索、推荐给用户的电影信息查询等)。
49 | 4. 用户点赞功接口实现(点赞信息暂存,再按时持久化到数据库)。
50 | 5. ...
51 |
--------------------------------------------------------------------------------
/README_IMG/系统功能模块.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/junweizeng/movie_recommendation_system_server/ef700cde27920be226f10d5e453ef154ea685396/README_IMG/系统功能模块.png
--------------------------------------------------------------------------------
/README_IMG/项目打成jar包.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/junweizeng/movie_recommendation_system_server/ef700cde27920be226f10d5e453ef154ea685396/README_IMG/项目打成jar包.png
--------------------------------------------------------------------------------
/mvnw.cmd:
--------------------------------------------------------------------------------
1 | @REM ----------------------------------------------------------------------------
2 | @REM Licensed to the Apache Software Foundation (ASF) under one
3 | @REM or more contributor license agreements. See the NOTICE file
4 | @REM distributed with this work for additional information
5 | @REM regarding copyright ownership. The ASF licenses this file
6 | @REM to you under the Apache License, Version 2.0 (the
7 | @REM "License"); you may not use this file except in compliance
8 | @REM with the License. You may obtain a copy of the License at
9 | @REM
10 | @REM https://www.apache.org/licenses/LICENSE-2.0
11 | @REM
12 | @REM Unless required by applicable law or agreed to in writing,
13 | @REM software distributed under the License is distributed on an
14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | @REM KIND, either express or implied. See the License for the
16 | @REM specific language governing permissions and limitations
17 | @REM under the License.
18 | @REM ----------------------------------------------------------------------------
19 |
20 | @REM ----------------------------------------------------------------------------
21 | @REM Maven Start Up Batch script
22 | @REM
23 | @REM Required ENV vars:
24 | @REM JAVA_HOME - location of a JDK home dir
25 | @REM
26 | @REM Optional ENV vars
27 | @REM M2_HOME - location of maven2's installed home dir
28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
31 | @REM e.g. to debug Maven itself, use
32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
34 | @REM ----------------------------------------------------------------------------
35 |
36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
37 | @echo off
38 | @REM set title of command window
39 | title %0
40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
42 |
43 | @REM set %HOME% to equivalent of $HOME
44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
45 |
46 | @REM Execute a user defined script before this one
47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending
49 | if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %*
50 | if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %*
51 | :skipRcPre
52 |
53 | @setlocal
54 |
55 | set ERROR_CODE=0
56 |
57 | @REM To isolate internal variables from possible post scripts, we use another setlocal
58 | @setlocal
59 |
60 | @REM ==== START VALIDATION ====
61 | if not "%JAVA_HOME%" == "" goto OkJHome
62 |
63 | echo.
64 | echo Error: JAVA_HOME not found in your environment. >&2
65 | echo Please set the JAVA_HOME variable in your environment to match the >&2
66 | echo location of your Java installation. >&2
67 | echo.
68 | goto error
69 |
70 | :OkJHome
71 | if exist "%JAVA_HOME%\bin\java.exe" goto init
72 |
73 | echo.
74 | echo Error: JAVA_HOME is set to an invalid directory. >&2
75 | echo JAVA_HOME = "%JAVA_HOME%" >&2
76 | echo Please set the JAVA_HOME variable in your environment to match the >&2
77 | echo location of your Java installation. >&2
78 | echo.
79 | goto error
80 |
81 | @REM ==== END VALIDATION ====
82 |
83 | :init
84 |
85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
86 | @REM Fallback to current working directory if not found.
87 |
88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
90 |
91 | set EXEC_DIR=%CD%
92 | set WDIR=%EXEC_DIR%
93 | :findBaseDir
94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound
95 | cd ..
96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound
97 | set WDIR=%CD%
98 | goto findBaseDir
99 |
100 | :baseDirFound
101 | set MAVEN_PROJECTBASEDIR=%WDIR%
102 | cd "%EXEC_DIR%"
103 | goto endDetectBaseDir
104 |
105 | :baseDirNotFound
106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
107 | cd "%EXEC_DIR%"
108 |
109 | :endDetectBaseDir
110 |
111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
112 |
113 | @setlocal EnableExtensions EnableDelayedExpansion
114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
116 |
117 | :endReadAdditionalConfig
118 |
119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
122 |
123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
124 |
125 | FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
127 | )
128 |
129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data.
131 | if exist %WRAPPER_JAR% (
132 | if "%MVNW_VERBOSE%" == "true" (
133 | echo Found %WRAPPER_JAR%
134 | )
135 | ) else (
136 | if not "%MVNW_REPOURL%" == "" (
137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
138 | )
139 | if "%MVNW_VERBOSE%" == "true" (
140 | echo Couldn't find %WRAPPER_JAR%, downloading it ...
141 | echo Downloading from: %DOWNLOAD_URL%
142 | )
143 |
144 | powershell -Command "&{"^
145 | "$webclient = new-object System.Net.WebClient;"^
146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
148 | "}"^
149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
150 | "}"
151 | if "%MVNW_VERBOSE%" == "true" (
152 | echo Finished downloading %WRAPPER_JAR%
153 | )
154 | )
155 | @REM End of extension
156 |
157 | @REM Provide a "standardized" way to retrieve the CLI args that will
158 | @REM work with both Windows and non-Windows executions.
159 | set MAVEN_CMD_LINE_ARGS=%*
160 |
161 | %MAVEN_JAVA_EXE% ^
162 | %JVM_CONFIG_MAVEN_PROPS% ^
163 | %MAVEN_OPTS% ^
164 | %MAVEN_DEBUG_OPTS% ^
165 | -classpath %WRAPPER_JAR% ^
166 | "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^
167 | %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
168 | if ERRORLEVEL 1 goto error
169 | goto end
170 |
171 | :error
172 | set ERROR_CODE=1
173 |
174 | :end
175 | @endlocal & set ERROR_CODE=%ERROR_CODE%
176 |
177 | if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost
178 | @REM check for post script, once with legacy .bat ending and once with .cmd ending
179 | if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat"
180 | if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd"
181 | :skipRcPost
182 |
183 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
184 | if "%MAVEN_BATCH_PAUSE%"=="on" pause
185 |
186 | if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE%
187 |
188 | cmd /C exit /B %ERROR_CODE%
189 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.springframework.boot
7 | spring-boot-starter-parent
8 | 2.6.6
9 |
10 |
11 | cn.zjw
12 | mrs
13 | 0.0.1-SNAPSHOT
14 | movie_recommendation_system
15 | movie_recommendation_system
16 |
17 | 1.8
18 |
19 |
20 |
21 | org.springframework.boot
22 | spring-boot-starter-web
23 |
24 |
25 | org.mybatis.spring.boot
26 | mybatis-spring-boot-starter
27 | 2.2.2
28 |
29 |
30 | org.springframework.boot
31 | spring-boot-starter-security
32 |
33 |
34 | org.springframework.boot
35 | spring-boot-starter-mail
36 |
37 |
38 |
39 | org.springframework.boot
40 | spring-boot-devtools
41 | runtime
42 | true
43 |
44 |
45 | mysql
46 | mysql-connector-java
47 | runtime
48 |
49 |
50 | org.springframework.boot
51 | spring-boot-configuration-processor
52 | true
53 |
54 |
55 | org.projectlombok
56 | lombok
57 | true
58 |
59 |
60 | org.springframework.boot
61 | spring-boot-starter-test
62 | test
63 |
64 |
65 | com.baomidou
66 | mybatis-plus-boot-starter
67 | 3.5.1
68 |
69 |
70 | cn.hutool
71 | hutool-all
72 | 5.8.21
73 |
74 |
75 |
76 |
77 | org.springframework.boot
78 | spring-boot-starter-data-redis
79 |
80 |
81 |
82 | com.alibaba
83 | fastjson
84 | 1.2.83
85 |
86 |
87 |
88 | io.jsonwebtoken
89 | jjwt
90 | 0.9.1
91 |
92 |
93 |
94 | com.aliyun.oss
95 | aliyun-sdk-oss
96 | 3.14.0
97 |
98 |
99 |
100 | org.nd4j
101 | nd4j-native-platform
102 | 1.0.0-beta7
103 |
104 |
105 |
106 | org.apache.mahout
107 | mahout-core
108 | 0.9
109 |
110 |
111 | org.apache.mahout
112 | mahout-integration
113 | 0.9
114 |
115 |
116 |
117 |
118 | mysql
119 | mysql-connector-java
120 | 8.0.28
121 |
122 |
123 |
124 |
125 | com.huaban
126 | jieba-analysis
127 | 1.0.2
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 | org.springframework.boot
136 | spring-boot-maven-plugin
137 |
138 |
139 |
140 | org.projectlombok
141 | lombok
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
--------------------------------------------------------------------------------
/src/main/java/cn/zjw/mrs/MovieRecommendationSystemApplication.java:
--------------------------------------------------------------------------------
1 | package cn.zjw.mrs;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.scheduling.annotation.EnableScheduling;
6 |
7 | /**
8 | * @author zjw
9 | */
10 | @SpringBootApplication
11 | @EnableScheduling
12 | public class MovieRecommendationSystemApplication {
13 |
14 | public static void main(String[] args) {
15 | SpringApplication.run(MovieRecommendationSystemApplication.class, args);
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/java/cn/zjw/mrs/config/CorsConfig.java:
--------------------------------------------------------------------------------
1 | package cn.zjw.mrs.config;
2 |
3 | import org.springframework.context.annotation.Configuration;
4 | import org.springframework.web.servlet.config.annotation.CorsRegistry;
5 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
6 |
7 | /**
8 | * @author zjw
9 | * @Classname CorsConfig
10 | * @Date 2022/4/7 22:31
11 | * @Description
12 | */
13 | @Configuration
14 | public class CorsConfig implements WebMvcConfigurer {
15 | @Override
16 | public void addCorsMappings(CorsRegistry registry) {
17 | // 设置允许跨域的路径
18 | registry.addMapping("/**")
19 | // 设置允许跨域请求的域名
20 | .allowedOriginPatterns("*")
21 | // 是否允许cookie
22 | .allowCredentials(true)
23 | // 设置允许的请求方式
24 | .allowedMethods("GET", "POST", "DELETE", "PUT")
25 | // 设置允许的header属性
26 | .allowedHeaders("*")
27 | // 跨域允许时间
28 | .maxAge(3600);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/cn/zjw/mrs/config/ExecutorConfig.java:
--------------------------------------------------------------------------------
1 | package cn.zjw.mrs.config;
2 |
3 | import org.slf4j.Logger;
4 | import org.slf4j.LoggerFactory;
5 | import org.springframework.context.annotation.Bean;
6 | import org.springframework.context.annotation.Configuration;
7 | import org.springframework.scheduling.annotation.EnableAsync;
8 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
9 |
10 | import java.util.concurrent.Executor;
11 | import java.util.concurrent.ThreadPoolExecutor;
12 |
13 | /**
14 | * @author zjw
15 | * @Classname ExecutorConfig
16 | * @Date 2022/4/23 20:39
17 | * @Description
18 | */
19 | @Configuration
20 | @EnableAsync
21 | public class ExecutorConfig {
22 |
23 | private static final Logger logger = LoggerFactory.getLogger(ExecutorConfig.class);
24 |
25 | private static final int CPU_NUM = Runtime.getRuntime().availableProcessors();
26 |
27 | private static final int QUEUE_CAPACITY = 99999;
28 |
29 | @Bean
30 | public Executor asyncServiceExecutor() {
31 | logger.info("start asyncServiceExecutor");
32 | ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
33 | // 配置核心线程数
34 | executor.setCorePoolSize(CPU_NUM + 1);
35 | // 配置最大线程数
36 | executor.setMaxPoolSize(CPU_NUM + 1);
37 | // 配置队列大小
38 | executor.setQueueCapacity(QUEUE_CAPACITY);
39 | // 配置线程池中的线程的名称前缀
40 | executor.setThreadNamePrefix("async-service-");
41 |
42 | // rejection-policy:当pool已经达到max size的时候,如何处理新任务
43 | // CALLER_RUNS:不在新线程中执行任务,而是由调用者所在的线程来执行
44 | executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
45 | // 执行初始化
46 | executor.initialize();
47 | return executor;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/main/java/cn/zjw/mrs/config/MySqlDataModelConfig.java:
--------------------------------------------------------------------------------
1 | package cn.zjw.mrs.config;
2 |
3 | import com.mysql.cj.jdbc.MysqlDataSource;
4 | import org.apache.mahout.cf.taste.impl.model.jdbc.MySQLJDBCDataModel;
5 | import org.apache.mahout.cf.taste.model.DataModel;
6 | import org.apache.mahout.cf.taste.model.JDBCDataModel;
7 | import org.springframework.beans.factory.annotation.Value;
8 | import org.springframework.context.annotation.Bean;
9 |
10 |
11 | /**
12 | * @author zjw
13 | * @Classname MySqlDataModelConfig
14 | * @Date 2022/5/1 20:11
15 | * @Description
16 | */
17 |
18 | public class MySqlDataModelConfig {
19 |
20 | @Value("${spring.datasource.username}")
21 | private String username;
22 | @Value("${spring.datasource.password}")
23 | private String password;
24 |
25 | @Bean
26 | public DataModel getMySqlDataModel() {
27 | MysqlDataSource dataSource = new MysqlDataSource();
28 | JDBCDataModel dataModel = null;
29 |
30 | try {
31 | dataSource.setServerName("rm-bp11602preg16q6g4jo.mysql.rds.aliyuncs.com");
32 | dataSource.setUser(username);
33 | dataSource.setPassword(password);
34 | dataSource.setServerTimezone("GMT%2B8");
35 | dataSource.setUseSSL(false);
36 | dataSource.setCharacterEncoding("utf-8");
37 |
38 | System.out.println("hello hello hello 1111111");
39 | System.out.println(dataSource);
40 | System.out.println();
41 |
42 | dataModel = new MySQLJDBCDataModel(dataSource,
43 | "comment",
44 | "uid",
45 | "mid",
46 | "score",
47 | "time");
48 |
49 | System.out.println("hello hello hello 1111111");
50 | System.out.println(dataModel);
51 | System.out.println();
52 | } catch (Exception e) {
53 | e.printStackTrace();
54 | }
55 |
56 | return dataModel;
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/main/java/cn/zjw/mrs/config/MybatisPlusConfig.java:
--------------------------------------------------------------------------------
1 | package cn.zjw.mrs.config;
2 |
3 | import com.baomidou.mybatisplus.annotation.DbType;
4 | import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
5 | import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
6 | import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
7 | import org.mybatis.spring.annotation.MapperScan;
8 | import org.springframework.context.annotation.Bean;
9 | import org.springframework.context.annotation.Configuration;
10 |
11 | /**
12 | * @author zjw
13 | * @Classname MybatisPlusConfig
14 | * @Date 2022/4/7 10:59
15 | * @Description
16 | *
17 | * MapperScan 用于扫描指定包下的Mapper接口
18 | */
19 | @Configuration
20 | @MapperScan("cn.zjw.mrs.mapper")
21 | public class MybatisPlusConfig {
22 |
23 | @Bean
24 | public MybatisPlusInterceptor mybatisPlusInterceptor() {
25 | MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
26 | // 添加分页插件
27 | interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
28 | // 添加乐观锁插件
29 | interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
30 | return interceptor;
31 | }
32 | }
--------------------------------------------------------------------------------
/src/main/java/cn/zjw/mrs/config/OssClientConfig.java:
--------------------------------------------------------------------------------
1 | package cn.zjw.mrs.config;
2 |
3 | import com.aliyun.oss.OSSClient;
4 | import com.aliyun.oss.OSSClientBuilder;
5 | import org.springframework.beans.factory.annotation.Value;
6 | import org.springframework.context.annotation.Bean;
7 | import org.springframework.context.annotation.Configuration;
8 |
9 | /**
10 | * @author zjw
11 | * @Classname OssClientConfig
12 | * @Date 2022/4/17 13:48
13 | * @Description
14 | */
15 | @Configuration
16 | public class OssClientConfig {
17 | @Value("${aliyun.oss.endpoint}")
18 | private String endpoint ;
19 | @Value("${aliyun.oss.accessKeyId}")
20 | private String accessKeyId ;
21 | @Value("${aliyun.oss.accessKeySecret}")
22 | private String accessKeySecret;
23 |
24 | @Bean
25 | public OSSClient createOssClient() {
26 | return (OSSClient) new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/java/cn/zjw/mrs/config/RedisConfig.java:
--------------------------------------------------------------------------------
1 | package cn.zjw.mrs.config;
2 |
3 | import cn.zjw.mrs.utils.FastJsonRedisSerializer;
4 | import com.alibaba.fastjson.parser.ParserConfig;
5 | import org.springframework.context.annotation.Bean;
6 | import org.springframework.context.annotation.Configuration;
7 | import org.springframework.data.redis.connection.RedisConnectionFactory;
8 | import org.springframework.data.redis.core.RedisTemplate;
9 | import org.springframework.data.redis.serializer.StringRedisSerializer;
10 |
11 | /**
12 | * @author zjw
13 | * @Classname RedisConfig
14 | * @Date 2022/5/22 18:26
15 | * @Description
16 | */
17 | @Configuration
18 | public class RedisConfig {
19 |
20 | /**
21 | * 配置redis,解决redis序列化后乱码问题
22 | */
23 | @Bean
24 | public RedisTemplate redisTemplate(RedisConnectionFactory redisConnectionFactory) {
25 | RedisTemplate redisTemplate = new RedisTemplate();
26 | redisTemplate.setConnectionFactory(redisConnectionFactory);
27 | FastJsonRedisSerializer