1、项目功能演示
DC00020基于springboot新闻网站系统java web项目MySQL
2、项目功能描述
基于springboot+vue新闻网站包括用户和系统管理员两个角色。
2.1 用户功能
1、用户登录、用户注册
2、新闻信息:点赞、点踩、收藏、查看
3、用户分享:点赞、点踩、收藏、查看、添加、搜索
4、公告信息:公告信息查看
5、个人信息:个人信息修改、我的收藏、退出系统
6、用户分享管理
7、我的收藏管理
2.2 系统管理员功能
1、系统登录
2、个人中心:修改密码、个人信息
3、用户管理
4、新闻类别管理
5、新闻管理
6、用户分享管理
7、系统管理:轮播图管理、公告管理
3、项目运行截图
4、项目核心代码
4.1 pom.xml
<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 http://maven.apache.org/maven-v4_0_0.xsd"><modelVersion>4.0.0</modelVersion><groupId>com.jlwl</groupId><artifactId>ssm41ge8</artifactId><packaging>war</packaging><version>1.0-SNAPSHOT</version><properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><spring.version>5.0.0.RELEASE</spring.version><junit.version>4.12</junit.version><druid.version>1.1.0</druid.version><fastjson.version>1.2.8</fastjson.version><mybaitsplus.version>2.3</mybaitsplus.version><mysql.version>5.1.38</mysql.version><log4j.version>1.2.17</log4j.version><slf4j.version>1.7.19</slf4j.version><aspectjweaver.version>1.8.8</aspectjweaver.version><fileupload.version>1.3.1</fileupload.version><jstl.version>1.2</jstl.version></properties><dependencies><!-- JUnit --><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>${junit.version}</version><scope>test</scope></dependency><!-- Spring --><dependency><groupId>org.springframework</groupId><artifactId>spring-core</artifactId><version>${spring.version}</version><type>jar</type><scope>compile</scope></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-context</artifactId><version>${spring.version}</version><type>jar</type><scope>compile</scope></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-context-support</artifactId><version>${spring.version}</version><type>jar</type><scope>compile</scope></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-tx</artifactId><version>${spring.version}</version><type>jar</type><scope>compile</scope></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-aop</artifactId><version>${spring.version}</version><type>jar</type><scope>compile</scope></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-beans</artifactId><version>${spring.version}</version><type>jar</type><scope>compile</scope></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-jdbc</artifactId><version>${spring.version}</version><type>jar</type><scope>compile</scope></dependency><!-- Spring MVC --><dependency><groupId>org.springframework</groupId><artifactId>spring-web</artifactId><version>${spring.version}</version><type>jar</type><scope>compile</scope></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-webmvc</artifactId><version>${spring.version}</version><type>jar</type><scope>compile</scope></dependency><!-- AOP --><dependency><groupId>org.aspectj</groupId><artifactId>aspectjweaver</artifactId><version>${aspectjweaver.version}</version></dependency><!-- FileUpload --><dependency><groupId>commons-fileupload</groupId><artifactId>commons-fileupload</artifactId><version>${fileupload.version}</version></dependency><dependency><groupId>javax.servlet</groupId><artifactId>jstl</artifactId><version>${jstl.version}</version></dependency><!-- Mybatis-Plus --><dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus</artifactId><version>${mybaitsplus.version}</version></dependency><!-- Mysql --><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>${mysql.version}</version></dependency><dependency><groupId>com.microsoft.sqlserver</groupId><artifactId>sqljdbc4</artifactId><scope>4.0</scope><version>4.0</version></dependency><dependency><groupId>com.microsoft.sqlserver</groupId><artifactId>mssql-jdbc</artifactId><version>6.2.0.jre8</version><scope>runtime</scope></dependency><!-- Druid --><dependency><groupId>com.alibaba</groupId><artifactId>druid</artifactId><version>${druid.version}</version></dependency><!-- FastJson --><dependency><groupId>com.alibaba</groupId><artifactId>fastjson</artifactId><version>${fastjson.version}</version></dependency><!-- Log --><dependency><groupId>log4j</groupId><artifactId>log4j</artifactId><version>${log4j.version}</version></dependency><dependency><groupId>org.slf4j</groupId><artifactId>slf4j-api</artifactId><version>${slf4j.version}</version></dependency><dependency><groupId>org.slf4j</groupId><artifactId>slf4j-log4j12</artifactId><version>${slf4j.version}</version></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-test</artifactId><version>${spring.version}</version></dependency><dependency><groupId>org.apache.commons</groupId><artifactId>commons-lang3</artifactId><version>3.0</version></dependency><dependency><groupId>javax.validation</groupId><artifactId>validation-api</artifactId><version>2.0.1.Final</version></dependency><dependency><groupId>commons-io</groupId><artifactId>commons-io</artifactId><version>2.5</version></dependency><dependency><groupId>cn.hutool</groupId><artifactId>hutool-all</artifactId><version>4.0.12</version></dependency><!-- https://mvnrepository.com/artifact/org.apache.tomcat.embed/tomcat-embed-core --><dependency><groupId>org.apache.tomcat.embed</groupId><artifactId>tomcat-embed-core</artifactId><version>9.0.29</version></dependency><!-- https://mvnrepository.com/artifact/commons-beanutils/commons-beanutils --><dependency><groupId>commons-beanutils</groupId><artifactId>commons-beanutils</artifactId><version>1.8.0</version></dependency><!-- 鐧惧害浜哄伐鏅鸿兘 --><dependency><groupId>com.baidu.aip</groupId><artifactId>java-sdk</artifactId><version>4.4.1</version></dependency><!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-annotations --><dependency><groupId>com.fasterxml.jackson.core</groupId><artifactId>jackson-annotations</artifactId><version>2.10.1</version></dependency><dependency><groupId>com.fasterxml.jackson.core</groupId><artifactId>jackson-databind</artifactId><version>2.10.1</version></dependency><dependency><groupId>org.codehaus.jackson</groupId><artifactId>jackson-mapper-asl</artifactId><version>1.9.13</version></dependency></dependencies><build><!-- 椤圭洰璁块棶鍚嶇О --><finalName>ssm41ge8</finalName><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><configuration><source>1.7</source><target>1.7</target></configuration></plugin></plugins></build>
</project>
4.2 spring-mybatis.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:tx="http://www.springframework.org/schema/tx"xmlns:aop="http://www.springframework.org/schema/aop"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/txhttp://www.springframework.org/schema/tx/spring-tx.xsdhttp://www.springframework.org/schema/aophttp://www.springframework.org/schema/aop/spring-aop.xsd"><!-- 配置数据源 --><bean name="dataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close"><property name="url" value="${jdbc_url}"/><property name="username" value="${jdbc_username}"/><property name="password" value="${jdbc_password}"/><!-- 初始化连接大小 --><property name="initialSize" value="0"/><!-- 连接池最大使用连接数量 --><property name="maxActive" value="20"/><!-- 连接池最大空闲 --><property name="maxIdle" value="20"/><!-- 连接池最小空闲 --><property name="minIdle" value="0"/><!-- 获取连接最大等待时间 --><property name="maxWait" value="60000"/><property name="validationQuery" value="${validationQuery}"/><property name="testOnBorrow" value="false"/><property name="testOnReturn" value="false"/><property name="testWhileIdle" value="true"/><!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 --><property name="timeBetweenEvictionRunsMillis" value="60000"/><!-- 配置一个连接在池中最小生存的时间,单位是毫秒 --><property name="minEvictableIdleTimeMillis" value="25200000"/><!-- 打开removeAbandoned功能 --><property name="removeAbandoned" value="true"/><!-- 1800秒,也就是30分钟 --><property name="removeAbandonedTimeout" value="1800"/><!-- 关闭abanded连接时输出错误日志 --><property name="logAbandoned" value="true"/><!-- 监控数据库 --><property name="filters" value="mergeStat"/></bean><!-- Spring整合Mybatis,更多查看文档:http://mp.baomidou.com --><bean id="sqlSessionFactory" class="com.baomidou.mybatisplus.spring.MybatisSqlSessionFactoryBean"><property name="dataSource" ref="dataSource"/><!-- 自动扫描Mapping.xml文件 --><property name="mapperLocations" value="classpath:mapper/*.xml"/><property name="configLocation" value="classpath:mybatis/mybatis-config.xml"/><property name="typeAliasesPackage" value="com..model.*"/><property name="typeEnumsPackage" value="com.model.enums"/><property name="plugins"><array><!-- 分页插件配置 --><bean id="paginationInterceptor" class="com.baomidou.mybatisplus.plugins.PaginationInterceptor"></bean></array></property><!-- 全局配置注入 --><property name="globalConfig" ref="globalConfig" /></bean><bean id="globalConfig" class="com.baomidou.mybatisplus.entity.GlobalConfiguration"><!--AUTO->`0`("数据库ID自增")INPUT->`1`(用户输入ID")ID_WORKER->`2`("全局唯一ID")UUID->`3`("全局唯一ID")--><property name="idType" value="2" /><!--MYSQL->`mysql`ORACLE->`oracle`DB2->`db2`H2->`h2`HSQL->`hsql`SQLITE->`sqlite`POSTGRE->`postgresql`SQLSERVER2005->`sqlserver2005`SQLSERVER->`sqlserver`--><!-- Oracle需要添加该项 --><!-- <property name="dbType" value="oracle" /> --><!-- 全局表为下划线命名设置 true --><!-- <property name="dbColumnUnderline" value="true" /> --><property name="metaObjectHandler"><bean class="com.config.MyMetaObjectHandler" /></property></bean><!-- MyBatis 动态扫描 --><bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"><property name="basePackage" value="com.dao"/></bean><!-- 配置事务管理 --><bean name="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"><property name="dataSource" ref="dataSource"/></bean><!-- 事务管理 属性 --><tx:advice id="transactionAdvice" transaction-manager="transactionManager"><tx:attributes><tx:method name="add*" propagation="REQUIRED"/><tx:method name="append*" propagation="REQUIRED"/><tx:method name="save*" propagation="REQUIRED"/><tx:method name="update*" propagation="REQUIRED"/><tx:method name="modify*" propagation="REQUIRED"/><tx:method name="edit*" propagation="REQUIRED"/><tx:method name="insert*" propagation="REQUIRED"/><tx:method name="delete*" propagation="REQUIRED"/><tx:method name="remove*" propagation="REQUIRED"/><tx:method name="repair" propagation="REQUIRED"/><tx:method name="get*" propagation="REQUIRED" read-only="true"/><tx:method name="find*" propagation="REQUIRED" read-only="true"/><tx:method name="load*" propagation="REQUIRED" read-only="true"/><tx:method name="search*" propagation="REQUIRED" read-only="true"/><tx:method name="datagrid*" propagation="REQUIRED" read-only="true"/><tx:method name="*" propagation="REQUIRED"/></tx:attributes></tx:advice><!-- 配置切面 --><aop:config><aop:pointcut id="transactionPointcut" expression="execution(* com.service..*.*(..))"/><aop:advisor pointcut-ref="transactionPointcut" advice-ref="transactionAdvice"/></aop:config></beans>
4.3 hibernate-validator校验工具类
package com.utils;import java.util.Set;import javax.validation.ConstraintViolation;
import javax.validation.Validation;
import javax.validation.Validator;import com.entity.EIException;/*** hibernate-validator校验工具类*/
public class ValidatorUtils {private static Validator validator;static {validator = Validation.buildDefaultValidatorFactory().getValidator();}/*** 校验对象* @param object 待校验对象* @param groups 待校验的组* @throws EIException 校验不通过,则报EIException异常*/public static void validateEntity(Object object, Class<?>... groups)throws EIException {Set<ConstraintViolation<Object>> constraintViolations = validator.validate(object, groups);if (!constraintViolations.isEmpty()) {ConstraintViolation<Object> constraint = (ConstraintViolation<Object>)constraintViolations.iterator().next();throw new EIException(constraint.getMessage());}}}
4.4 HttpClient工具类
package com.utils;import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;/*** HttpClient工具类*/
public class HttpClientUtils {/*** @param uri* @return String* @description get请求方式* @author: long.he01*/public static String doGet(String uri) {StringBuilder result = new StringBuilder();try {String res = "";URL url = new URL(uri);HttpURLConnection conn = (HttpURLConnection) url.openConnection();BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));String line;while ((line = in.readLine()) != null) {res += line+"\n";}in.close();return res;}catch (Exception e) {e.printStackTrace();return null;}}}
4.5 Mybatis-Plus工具类
package com.utils;import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;import org.apache.commons.lang3.StringUtils;import cn.hutool.core.bean.BeanUtil;import com.baomidou.mybatisplus.mapper.Wrapper;/*** Mybatis-Plus工具类*/
public class MPUtil {public static final char UNDERLINE = '_';//mybatis plus allEQ 表达式转换public static Map allEQMapPre(Object bean,String pre) {Map<String, Object> map =BeanUtil.beanToMap(bean);return camelToUnderlineMap(map,pre);}//mybatis plus allEQ 表达式转换public static Map allEQMap(Object bean) {Map<String, Object> map =BeanUtil.beanToMap(bean);return camelToUnderlineMap(map,"");}public static Wrapper allLikePre(Wrapper wrapper,Object bean,String pre) {Map<String, Object> map =BeanUtil.beanToMap(bean);Map result = camelToUnderlineMap(map,pre);return genLike(wrapper,result);}public static Wrapper allLike(Wrapper wrapper,Object bean) {Map result = BeanUtil.beanToMap(bean, true, true); return genLike(wrapper,result);}public static Wrapper genLike( Wrapper wrapper,Map param) {Iterator<Map.Entry<String, Object>> it = param.entrySet().iterator();int i=0;while (it.hasNext()) {if(i>0) wrapper.and();Map.Entry<String, Object> entry = it.next();String key = entry.getKey();String value = (String) entry.getValue();wrapper.like(key, value);i++;}return wrapper;}public static Wrapper likeOrEq(Wrapper wrapper,Object bean) {Map result = BeanUtil.beanToMap(bean, true, true); return genLikeOrEq(wrapper,result);}public static Wrapper genLikeOrEq( Wrapper wrapper,Map param) {Iterator<Map.Entry<String, Object>> it = param.entrySet().iterator();int i=0;while (it.hasNext()) {if(i>0) wrapper.and();Map.Entry<String, Object> entry = it.next();String key = entry.getKey();if(entry.getValue().toString().contains("%")) {wrapper.like(key, entry.getValue().toString().replace("%", ""));} else {wrapper.eq(key, entry.getValue());}i++;}return wrapper;}public static Wrapper allEq(Wrapper wrapper,Object bean) {Map result = BeanUtil.beanToMap(bean, true, true); return genEq(wrapper,result);}public static Wrapper genEq( Wrapper wrapper,Map param) {Iterator<Map.Entry<String, Object>> it = param.entrySet().iterator();int i=0;while (it.hasNext()) {if(i>0) wrapper.and();Map.Entry<String, Object> entry = it.next();String key = entry.getKey();wrapper.eq(key, entry.getValue());i++;}return wrapper;}public static Wrapper between(Wrapper wrapper,Map<String, Object> params) {for(String key : params.keySet()) {String columnName = "";if(key.endsWith("_start")) {columnName = key.substring(0, key.indexOf("_start"));if(StringUtils.isNotBlank(params.get(key).toString())) {wrapper.ge(columnName, params.get(key));}}if(key.endsWith("_end")) {columnName = key.substring(0, key.indexOf("_end"));if(StringUtils.isNotBlank(params.get(key).toString())) {wrapper.le(columnName, params.get(key));}}}return wrapper;}public static Wrapper sort(Wrapper wrapper,Map<String, Object> params) {String order = "";if(params.get("order") != null && StringUtils.isNotBlank(params.get("order").toString())) {order = params.get("order").toString();}if(params.get("sort") != null && StringUtils.isNotBlank(params.get("sort").toString())) {if(order.equalsIgnoreCase("desc")) {wrapper.orderDesc(Arrays.asList(params.get("sort")));} else {wrapper.orderAsc(Arrays.asList(params.get("sort")));}}return wrapper;}/*** 驼峰格式字符串转换为下划线格式字符串* * @param param* @return*/public static String camelToUnderline(String param) {if (param == null || "".equals(param.trim())) {return "";}int len = param.length();StringBuilder sb = new StringBuilder(len);for (int i = 0; i < len; i++) {char c = param.charAt(i);if (Character.isUpperCase(c)) {sb.append(UNDERLINE);sb.append(Character.toLowerCase(c));} else {sb.append(c);}}return sb.toString();}public static void main(String[] ages) {System.out.println(camelToUnderline("ABCddfANM"));}public static Map camelToUnderlineMap(Map param, String pre) {Map<String, Object> newMap = new HashMap<String, Object>();Iterator<Map.Entry<String, Object>> it = param.entrySet().iterator();while (it.hasNext()) {Map.Entry<String, Object> entry = it.next();String key = entry.getKey();String newKey = camelToUnderline(key);if (pre.endsWith(".")) {newMap.put(pre + newKey, entry.getValue());} else if (StringUtils.isEmpty(pre)) {newMap.put(newKey, entry.getValue());} else {newMap.put(pre + "." + newKey, entry.getValue());}}return newMap;}
}
5、项目内容包含
6、项目获取
6.1 方式一
私聊或者扫描下方名片获取项目源码。
6.2 方式二
点击此处直接获取项目源码。