基于struts2、hibernate、spring、shiro、MySQL的项目开发

使用maven管理jar包的依赖

< 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/xsd/maven-4.0.0.xsd “ >
      < modelVersion > 4.0.0 </ modelVersion >
      < groupId > com.dabai </ groupId >
      < artifactId > test-parent </ artifactId >
      < version > 0.0.1-SNAPSHOT </ version >
      < 包装 > pom </ packaging >
      < name > parent </ name >
      < description >父</ description >
    
      < properties >
            < spring .version> 4.2.4.RELEASE </ spring .version>
            < hibernate .version> 5.0.7.Final </ hibernate .version>
            < struts2 .version> 2.3.24 </ struts2 .version>
            < slf4j .version> 1.6.6 </ slf4j .version>
            < log4j .version> 1.2.12 </ log4j .version>
            < shiro .version> 1.2.3 </ shiro .version>
        </ properties >
    
        < dependencies >
            < 依赖 >
                < groupId > org.springframework </ groupId >
                < artifactId > spring-context </ artifactId >
                < version > $ {spring.version} </ version >
            </ dependency >
    
            < 依赖 >
                < groupId > org.springframework </ groupId >
                < artifactId > spring-context-support </ artifactId >
                < version > $ {spring.version} </ version >
            </ dependency >
    
            < 依赖 >
                < groupId > org.springframework </ groupId >
                < artifactId > spring-web </ artifactId >
                < version > $ {spring.version} </ version >
            </ dependency >
    
            < 依赖 >
                < groupId > org.springframework </ groupId >
                < artifactId > spring-orm </ artifactId >
                < version > $ {spring.version} </ version >
            </ dependency >
    
            < 依赖 >
                < groupId > org.springframework </ groupId >
                < artifactId > spring-beans </ artifactId >
                < version > $ {spring.version} </ version >
            </ dependency >
    
            < 依赖 >
                < groupId > org.springframework </ groupId >
                < artifactId > spring-core </ artifactId >
                < version > $ {spring.version} </ version >
            </ dependency >
    
            < 依赖 >
                < groupId > org.aspectj </ groupId >
                < artifactId > aspectjweaver </ artifactId >
                < version > 1.7.4 </ version >
            </ dependency >
    
            <! - struts2开始- >
            < 依赖 >
                < groupId > org.apache.struts </ groupId >
                < artifactId > struts2-core </ artifactId >
                < version > $ {struts2.version} </ version >
                <! -排除传递的依赖- >
                < exclusions >
                    < 排除 >
                        < artifactId > javassist </ artifactId >
                        < groupId > javassist </ groupId >
                    </ exclusion >
                </ exclusions >
            </ dependency >
            < 依赖 >
                < groupId > org.apache.struts </ groupId >
                < artifactId > struts2-spring-plugin </ artifactId >
                < version > $ {struts2.version} </ version >
            </ dependency >
            < 依赖 >
                < groupId > org.apache.struts </ groupId >
                < artifactId > struts2-convention-plugin </ artifactId >
                < version > $ {struts2.version} </ version >
            </ dependency >
            <! - struts2 end - >
    
            <! - hibernate begin - >
            < 依赖 >
                < groupId > org.hibernate </ groupId >
                < artifactId > hibernate-core </ artifactId >
                < version > $ {hibernate.version} </ version >
            </ dependency >
            <! - hibernate end - >
    
            <! - log start - >
            < 依赖 >
                < groupId > log4j </ groupId >
                < artifactId > log4j </ artifactId >
                < version > $ {log4j.version} </ version >
            </ dependency >
    
            < 依赖 >
                < groupId > org.slf4j </ groupId >
                < artifactId > slf4j-api </ artifactId >
                < version > $ {slf4j.version} </ version >
            </ dependency >
    
            < 依赖 >
                < groupId > org.slf4j </ groupId >
                < artifactId > slf4j-log4j12 </ artifactId >
                < version > $ {slf4j.version} </ version >
            </ dependency >
            <! - log end - >
    
            < 依赖 >
                < groupId > org.apache.poi </ groupId >
                < artifactId > poi </ artifactId >
                < version > 3.11 </ version >
            </ dependency >
    
            < 依赖 >
                < groupId > org.apache.cxf </ groupId >
                < artifactId > cxf-rt-frontend-jaxws </ artifactId >
                < version > 3.0.1 </ version >
            </ dependency >
            < 依赖 >
                < groupId > org.apache.cxf </ groupId >
                < artifactId > cxf-rt-transports-http </ artifactId >
                < version > 3.0.1 </ version >
            </ dependency >
            < 依赖 >
                < groupId > junit </ groupId >
                < artifactId > junit </ artifactId >
                < version > 4.10 </ version >
                < scope > test </ scope >
            </ dependency >
    
            <! -加入的servlet和JSP的依赖- >
            < 依赖 >
                < groupId > javax.servlet </ groupId >
                < artifactId > servlet-api </ artifactId >
                < version > 2.5 </ version >
                < scope >提供</ scope >
            </ dependency >
            < 依赖 >
                < groupId > javax.servlet </ groupId >
                < artifactId > jsp-api </ artifactId >
                < version > 2.0 </ version >
                < scope >提供</ scope >
            </ dependency >
    
            <! -引入pinyin4J的依赖- >
            < 依赖 >
                < groupId > com.belerweb </ groupId >
                < artifactId > pinyin4j </ artifactId >
                < version > 2.5.0 </ version >
            </ dependency >
    
            <! -引入JSON-lib中的依赖- >
            < 依赖 >
                < groupId > net.sf.json-lib </ groupId >
                < artifactId > json-lib </ artifactId >
                < version > 2.4 </ version >
            </ dependency >
    
            <! -引入c3p0jar包- >
            < 依赖 >
                < groupId > c3p0 </ groupId >
                < artifactId > c3p0 </ artifactId >
                < version > 0.9.1.2 </ version >
            </ dependency >
    
            <! -引入了Ehcache的依赖- >
            < 依赖 >
                < groupId > net.sf.ehcache </ groupId >
                < artifactId > ehcache-core </ artifactId >
                < version > 2.6.6 </ version >
            </ dependency >
            <! -引入四郎框架的依赖- >
            < 依赖 >
                < groupId > org.apache.shiro </ groupId >
                < artifactId > shiro-all </ artifactId >
                < version > 1.2.2 </ version >
            </ dependency >
            <! -引入MySQL的数据库驱动依赖- >
            < 依赖 >
                < groupId > mysql </ groupId >
                < artifactId > mysql-connector-java </ artifactId >
                < version > 5.1.32 </ version >
            </ dependency >
        </ dependencies >
        < build >
            <! -插件- >
            < plugins >
                < 插件 >
                    < groupId > org.apache.maven.plugins </ groupId >
                    < artifactId > maven-resources-plugin </ artifactId >
                    < version > 2.5 </ version >
                </ plugin >
                < 插件 >
                    < groupId > org.apache.maven.plugins </ groupId >
                    < artifactId > maven-compiler-plugin </ artifactId >
                    < version > 2.3.2 </ version >
                    < 配置 >
                        < source > 1.7 </ source >
                        < target > 1.7 </ target >
                    </ configuration >
                </ plugin >
                <! -引入Tomcat的插件- >
                < 插件 >
                    < groupId > org.apache.tomcat.maven </ groupId >
                    < artifactId > tomcat7-maven-plugin </ artifactId >
                    < version > 2.2 </ version >
                    < 配置 >
                        < path > / bos </ path >
                        < port > 8888 </ port >
                    </ configuration >
                </ plugin >
            </ plugins >
            < resources >
                < 资源 >
                    < directory > src / main / java </ directory >
                    < includes >
                        < include > ** / *。properties </ include >
                        < include > ** / *。xml </ include >
                    </ includes >
                    < filtering > false </ filtering >
                </ resource >
                < 资源 >
                    < directory > src / main / resources </ directory >
                    < includes >
                        < include > ** / *。properties </ include >
                        < include > ** / *。xml </ include >
                    </ includes >
                    < filtering > false </ filtering >
                </ resource >
            </ resources >
        </ build >
    
    
    
    
    
    
      < modules >
          < module > test-entity </ module >
          < module > test-web </ module >
          < module > test-utils </ module >
          < module > test-service </ module >
          < module > test-dao </ module >
      </ modules >
    </ project 
View Code

实体和实体对应的hibernate映射文件

dao层:从上往下是baseDao一个抽取类 ,dao层接口类  dao层实现类

全部代码:https://github.com/Danovercast/study.git

 最下面那个是webservice服务调用  是另外一个

原文地址:https://www.cnblogs.com/notably/p/10631014.html