wordpress搭建外贸网站,wordpress emlog,王野动力,html变WordpressJavaEE#xff1a;SpringSpringMVCMybatis项目—企业权限管理系统 首先给出项目演示地址#xff1a;http://www.youngxy.top:8080/SSM/
项目架构图#xff1a; 一#xff1a;功能需求
1.1 商品查询 基于SSM整合基础上完成商品查询#xff0c;要掌握主面页面main.jsp及商…JavaEESpringSpringMVCMybatis项目—企业权限管理系统 首先给出项目演示地址http://www.youngxy.top:8080/SSM/
项目架构图 一功能需求
1.1 商品查询 基于SSM整合基础上完成商品查询要掌握主面页面main.jsp及商品显示页面product-list.jsp页面的创建。 1.3 商品添加 进一步巩固SSM整合并完成商品添加功能要注意事务操作以及product-add.jsp页面生成。 1.2 订单查询 订单的查询操作它主要完成简单的多表查询操作查询订单时需要查询出与订单关联的其它表中信息所以大 家一定要了解订单及其它表关联关系 1.3 订单分页查询 订单分页查询我们使用的是mybatis分页插件PageHelper要掌握PageHelper的基本使用。 1.4 订单详情查询 订单详情是用于查询某一个订单的信息这个知识点主要考核学生对复杂的多表查询操作的掌握。 1.5 Spring Security 概述 Spring Security是 Spring 项目组中用来提供安全认证服务的框架它的使用很复杂我们在课程中只介绍了 spring Security的基本操作大家要掌握spring Security框架的配置及基本的认证与授权操作。 1.8 用户管理 用户管理中我们会介绍基于spring Security的用户登录、退出操作。以及用户查询、添加、详情有等操作这些功 能的练习是对前期SSM知识点的进一步巩固。 1.9 角色管理 角色管理主要完成角色查询、角色添加 。 1.10 资源权限管理 资源权限管理主要完成查询、添加操作它的操作与角色管理类似角色管理以及资源权限管理都是对权限管理的 补充。 1.11 权限关联与控制 主要会讲解用户角色关联、角色权限关联这两个操作是为了后续我们完成授权操作的基础关于授权操作我们会 在服务器端及页面端分别讲解 。 1.12 AOP日志处理 AOP日志处理我们使用spring AOP切面来完成系统级别的日志收集。 二项目架构
1.1技术选型
Spring、SpringMVC、Mybatis框架整合这样解决了业务层、dao层、表现层代码的繁琐。
在用户登陆认证过程中采用Spring Security框架进行权限管理。
页面数据展示分页时采用PageHelper插件管理。
后台界面采用流行的AdminLTE模板。 三前期准备
1.1数据库
首先基于Oracle的数据库要创建用户之后创建表结构。
在这里博主给出了项目Sql的文件点此下载。 1.2AdminLTE
大家可以参考官网教程或者使用本项目的中文模板。
点此下载本项目模板。 四环境搭建 1.1开发环境
创建Maven工程采用模板创建 然后创建不同模块 在工程总pom.xml文件中导入相关依赖
?xml version1.0 encodingUTF-8?
project xmlnshttp://maven.apache.org/POM/4.0.0xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsdmodelVersion4.0.0/modelVersiongroupIdcom.xy/groupIdartifactIdSSM/artifactIdpackagingpom/packagingversion1.0-SNAPSHOT/versionpropertiesproject.build.sourceEncodingUTF-8/project.build.sourceEncodingmaven.compiler.source1.8/maven.compiler.sourcemaven.compiler.target1.8/maven.compiler.targetspring.version5.1.6.RELEASE/spring.versionslf4j.version1.6.6/slf4j.versionlog4j.version1.2.12/log4j.versionmysql.version5.1.6/mysql.versionoracle.version11.2.0/oracle.versionmybatis.version3.4.5/mybatis.versionspring.security.version5.0.1.RELEASE/spring.security.version/propertiesdependenciesdependencygroupIdjunit/groupIdartifactIdjunit/artifactIdversion4.11/versionscopecompile/scope/dependency!-- spring --dependencygroupIdorg.aspectj/groupIdartifactIdaspectjweaver/artifactId version1.6.8/version/dependencydependencygroupIdorg.springframework/groupId artifactIdspring-aop/artifactIdversion${spring.version}/version /dependencydependencygroupIdorg.springframework/groupId artifactIdspring-context/artifactId version${spring.version}/version/dependencydependencygroupIdorg.springframework/groupId artifactIdspring-web/artifactIdversion${spring.version}/version /dependencydependencygroupIdorg.springframework/groupId artifactIdspring-webmvc/artifactId version${spring.version}/version/dependencydependencygroupIdorg.springframework/groupId artifactIdspring-test/artifactId version${spring.version}/version/dependencydependencygroupIdorg.springframework/groupId artifactIdspring-tx/artifactIdversion${spring.version}/version /dependencydependencygroupIdorg.springframework/groupId artifactIdspring-jdbc/artifactId version${spring.version}/version/dependencydependencygroupIdmysql/groupIdartifactIdmysql-connector-java/artifactId version${mysql.version}/version/dependencydependencygroupIdjavax.servlet/groupIdartifactIdservlet-api/artifactIdversion2.5/versionscopeprovided/scope/dependencydependencygroupIdjavax.servlet.jsp/groupIdartifactIdjsp-api/artifactIdversion2.0/versionscopeprovided/scope/dependencydependencygroupIdjstl/groupIdartifactIdjstl/artifactIdversion1.2/version/dependency!-- log start --dependencygroupIdlog4j/groupIdartifactIdlog4j/artifactIdversion${log4j.version}/version/dependencydependencygroupIdorg.slf4j/groupIdartifactIdslf4j-api/artifactIdversion${slf4j.version}/version/dependencydependencygroupIdorg.slf4j/groupIdartifactIdslf4j-log4j12/artifactIdversion${slf4j.version}/version/dependency!-- log end --dependencygroupIdorg.mybatis/groupIdartifactIdmybatis/artifactIdversion${mybatis.version}/version/dependencydependencygroupIdorg.mybatis/groupIdartifactIdmybatis-spring/artifactIdversion2.0.1/version/dependencydependencygroupIdc3p0/groupIdartifactIdc3p0/artifactIdversion0.9.1.2/versiontypejar/typescopecompile/scope/dependencydependencygroupIdcom.github.pagehelper/groupIdartifactIdpagehelper/artifactIdversion5.1.2/version/dependencydependencygroupIdorg.springframework.security/groupIdartifactIdspring-security-web/artifactIdversion${spring.security.version}/version/dependencydependencygroupIdorg.springframework.security/groupIdartifactIdspring-security-config/artifactIdversion${spring.security.version}/version/dependencydependencygroupIdorg.springframework.security/groupIdartifactIdspring-security-core/artifactIdversion${spring.security.version}/version/dependencydependencygroupIdorg.springframework.security/groupIdartifactIdspring-security-taglibs/artifactIdversion${spring.security.version}/version/dependencydependencygroupIdcom.oracle/groupIdartifactIdojdbc6/artifactIdversion${oracle.version}/version/dependency/dependenciesmodulesmoduleSSM_domain/modulemoduleSSM_dao/modulemoduleSSM_service/modulemoduleSSM_utils/modulemoduleSSM_web/module/modules/project 1.2框架搭建
在web模块下创建资源文件夹 新建配置文件如下
db.properties
jdbc.driveroracle.jdbc.driver.OracleDriver
jdbc.urljdbc:oracle:thin:127.0.0.1:1521:orcl
jdbc.usernamessm
jdbc.passwordylh013954
spring.jpa.properties.hibernate.dialectorg.hibernate.dialect.Oracle10gDialect把相关数据库用户名和密码修改成能运行。
log4j.properties
# Set root category priority to INFO and its only appender to CONSOLE.
#log4j.rootCategoryINFO, CONSOLE debug info warn error fatal
log4j.rootCategoryinfo, CONSOLE, LOGFILE# Set the enterprise logger category to FATAL and its only appender to CONSOLE.
log4j.logger.org.apache.axis.enterpriseFATAL, CONSOLE# CONSOLE is set to be a ConsoleAppender using a PatternLayout.
log4j.appender.CONSOLEorg.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layoutorg.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern%d{ISO8601} %-6r [%15.15t] %-5p %30.30c %x - %m\n# LOGFILE is set to be a File appender using a PatternLayout.
log4j.appender.LOGFILEorg.apache.log4j.FileAppender
log4j.appender.LOGFILE.Filed:/java/axis.log
log4j.appender.LOGFILE.Appendtrue
log4j.appender.LOGFILE.layoutorg.apache.log4j.PatternLayout
log4j.appender.LOGFILE.layout.ConversionPattern%d{ISO8601} %-6r [%15.15t] %-5p %30.30c %x - %m\n spring.xml:
?xml version1.0 encodingUTF-8?
beans xmlnshttp://www.springframework.org/schema/beansxmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexmlns:contexthttp://www.springframework.org/schema/contextxmlns:aophttp://www.springframework.org/schema/aopxmlns:txhttp://www.springframework.org/schema/txxsi:schemaLocationhttp://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context.xsdhttp://www.springframework.org/schema/aophttp://www.springframework.org/schema/aop/spring-aop.xsdhttp://www.springframework.org/schema/txhttp://www.springframework.org/schema/tx/spring-tx.xsd!-- 开启注解扫描管理service和dao --context:component-scan base-packagecom.xy.service/context:component-scancontext:component-scan base-packagecom.xy.dao/context:component-scancontext:property-placeholder locationclasspath:db.properties/!--spring整合mybatis--!-- 配置连接池 --bean iddataSource classcom.mchange.v2.c3p0.ComboPooledDataSourceproperty namedriverClass value${jdbc.driver} /property namejdbcUrl value${jdbc.url} /property nameuser value${jdbc.username} /property namepassword value${jdbc.password} //bean!-- 把交给IOC管理 SqlSessionFactory --bean idsqlSessionFactory classorg.mybatis.spring.SqlSessionFactoryBeanproperty namedataSource refdataSource /!-- 传入PageHelper的插件 --property namepluginsarray!-- 传入插件的对象 --bean classcom.github.pagehelper.PageInterceptorproperty namepropertiespropsprop keyhelperDialectmysql/propprop keyreasonabletrue/prop/props/property/bean/array/property/bean!-- 扫描dao接口 --bean idmapperScanner classorg.mybatis.spring.mapper.MapperScannerConfigurerproperty namebasePackage valuecom.xy.dao//bean!-- 配置Spring的声明式事务管理 --!-- 配置事务管理器 --bean iddataSourceTransactionManager classorg.springframework.jdbc.datasource.DataSourceTransactionManagerproperty namedataSource refdataSource//beantx:advice transaction-managerdataSourceTransactionManager idtxAdvicetx:attributestx:method namefind* read-onlytrue/tx:method name* isolationDEFAULT/tx:method/tx:attributes/tx:advice!--配置AOP增强--aop:configaop:advisor advice-reftxAdvice pointcutexecution(* com.xy.service.impl.*.*(..))/aop:advisor/aop:config
/beans spring-mvc.xml:
?xml version1.0 encodingUTF-8?
beans xmlnshttp://www.springframework.org/schema/beansxmlns:mvchttp://www.springframework.org/schema/mvcxmlns:contexthttp://www.springframework.org/schema/contextxmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexmlns:aophttp://www.springframework.org/schema/aopxsi:schemaLocationhttp://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/mvchttp://www.springframework.org/schema/mvc/spring-mvc.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context.xsdhttp://www.springframework.org/schema/aophttp://www.springframework.org/schema/aop/spring-aop.xsd!-- 扫描controller的注解别的不扫描 --context:component-scan base-packagecom.xy.controller/context:component-scan!-- 配置视图解析器 --bean idviewResolver classorg.springframework.web.servlet.view.InternalResourceViewResolver!-- JSP文件所在的目录 --property nameprefix value/pages/ /!-- 文件的后缀名 --property namesuffix value.jsp //bean!-- 设置不过滤静态资源--mvc:resources location/css/ mapping/css/** /mvc:resources location/img/ mapping/img/** /mvc:resources location/js/ mapping/js/** /mvc:resources location/plugins/ mapping/plugins/** /!-- 开启对SpringMVC注解的支持 --mvc:annotation-driven /aop:aspectj-autoproxy proxy-target-classtrue/
/beans1.3插件引入
需要spring security、pageHelper在pom.xml引入。
参考1.2 spring security.xml:
?xml version1.0 encodingUTF-8?
beans xmlnshttp://www.springframework.org/schema/beansxmlns:securityhttp://www.springframework.org/schema/securityxmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/securityhttp://www.springframework.org/schema/security/spring-security.xsd!--开启方法级权限控制--security:global-method-security jsr250-annotationsenabled secured-annotationsenabled pre-post-annotationsenabled/security:global-method-security!-- 配置不拦截的资源 --security:http pattern/login.jsp securitynone/security:http pattern/failer.jsp securitynone/security:http pattern/css/** securitynone/security:http pattern/img/** securitynone/security:http pattern/plugins/** securitynone/!--配置具体的规则auto-configtrue 不用自己编写登录的页面框架提供默认登录页面use-expressionsfalse 是否使用SPEL表达式没学习过--security:http auto-configtrue use-expressionsfalse!-- 配置具体的拦截的规则 pattern请求路径的规则 access访问系统的人必须有ROLE_USER的角色 --security:intercept-url pattern/** accessROLE_USER,ROLE_ADMIN/!-- 定义跳转的具体的页面 --security:form-loginlogin-page/login.jsplogin-processing-url/login.dodefault-target-url/index.jspauthentication-failure-url/failer.jsp/!-- 关闭跨域请求 --security:csrf disabledtrue/!-- 退出 --security:logout invalidate-sessiontrue logout-url/logout.do logout-success-url/login.jsp //security:http!--切换成数据库中的用户名和密码 --!--security:authentication-manager--!--security:authentication-provider user-service-refuserService--!--lt;!ndash;lt;!ndash; 配置加密的方式 ndash;gt;ndash;gt;--!--security:password-encoder refpasswordEncoder/--!--/security:authentication-provider--!--/security:authentication-manager--!-- 配置加密类 --!--bean idpasswordEncoder classorg.springframework.security.crypto.bcrypt.BCryptPasswordEncoder/--!-- 提供了入门的方式在内存中存入用户名和密码--security:authentication-managersecurity:authentication-providersecurity:user-servicesecurity:user nameadmin password{noop}admin authoritiesROLE_ADMIN//security:user-service/security:authentication-provider/security:authentication-manager
/beans 1.4Maven创建
完成以上工作项目初步构建成功可以在tomcat服务器上运行看是否能通过初步测试。 五代码实现 5.1dao层
如图编写代码 详细代码可以在项目源码查看这里给出代码逻辑及实现总体流程。 5.2业务层 5.3表现层 接下来介绍各个功能的具体实现细节
SpringSpringMVCMybatis项目—企业权限管理系统2 源码310508863