IDEA maven项目中多个项目之间的依赖加web项目

IDEA maven项目中多个项目之间的依赖加web项目(带数据连接oracle ssh)转载请附上原地址谢谢!
首先让我们看整体的框架结构:
IDEA maven项目中多个项目之间的依赖加web项目_第1张图片
接下来,我们先创建一个父类项目(pom类型的)
![在这里我直接进行下一步操作]IDEA maven项目中多个项目之间的依赖加web项目_第2张图片
IDEA maven项目中多个项目之间的依赖加web项目_第3张图片

IDEA maven项目中多个项目之间的依赖加web项目_第4张图片
创建好了父项目是这样的
IDEA maven项目中多个项目之间的依赖加web项目_第5张图片
erp_parent里面的pom.xml是这样的
IDEA maven项目中多个项目之间的依赖加web项目_第6张图片
接下来去创建子项目分别是:erp_biz,erp_dao,erp_entity,erp_web
IDEA maven项目中多个项目之间的依赖加web项目_第7张图片
IDEA maven项目中多个项目之间的依赖加web项目_第8张图片
下一步
IDEA maven项目中多个项目之间的依赖加web项目_第9张图片
下一步
IDEA maven项目中多个项目之间的依赖加web项目_第10张图片
erp_biz里面的pom.xml初始数据是:
IDEA maven项目中多个项目之间的依赖加web项目_第11张图片
这样我们第一个子项目就创建好了,其他几个同上(erp_web)注意他的打包方式是web包,我继续为大家搭建一下(erp_web子项目)。

IDEA maven项目中多个项目之间的依赖加web项目_第12张图片
按照我的指示一步步下来即可
IDEA maven项目中多个项目之间的依赖加web项目_第13张图片
IDEA maven项目中多个项目之间的依赖加web项目_第14张图片
IDEA maven项目中多个项目之间的依赖加web项目_第15张图片
创建所以项目完成后的样子
IDEA maven项目中多个项目之间的依赖加web项目_第16张图片
接下来,我们现在要做的是关联个个项目的依赖关系
IDEA maven项目中多个项目之间的依赖加web项目_第17张图片
IDEA maven项目中多个项目之间的依赖加web项目_第18张图片
IDEA maven项目中多个项目之间的依赖加web项目_第19张图片
IDEA maven项目中多个项目之间的依赖加web项目_第20张图片
其他的一样erp_biz依赖erp_dao,erp_web依赖erp_biz方法同上

献上全部代码:
erp_parent里面的pom.xml数据:



    4.0.0

    cn.wuyahui
    erp_parent
    1.0-SNAPSHOT
    pom
    
        erp_entity
        erp_dao
        erp_biz
        erp_web
    
    
    
        4.2.4.RELEASE
        2.3.24
        5.0.7.Final
    

    
        
            org.apache.struts
            struts2-core
            ${struts.version}
            
            
                
                    javassist
                    javassist
                
            
        
        
            org.hibernate
            hibernate-core
            ${hibernate.version}
        

        

        
        
            org.springframework
            spring-context
            4.2.2.RELEASE
        
        
        
            org.apache.struts
            struts2-spring-plugin
            ${struts.version}
        
        
        
            org.springframework
            spring-beans
            ${spring.version}
        
        
            org.springframework
            spring-core
            ${spring.version}
        
        
            org.springframework
            spring-context-support
            ${spring.version}
        
        
            org.springframework
            spring-aop
            ${spring.version}
        
        
            org.springframework
            spring-tx
            ${spring.version}
        
        
            org.springframework
            spring-orm
            ${spring.version}
        
        
            org.springframework
            spring-web
            ${spring.version}
        
        
            org.aspectj
            aspectjweaver
            1.8.7
        
        
            org.slf4j
            slf4j-api
            1.7.12
        
        
            org.slf4j
            slf4j-log4j12
            1.7.12
        
        
            c3p0
            c3p0
            0.9.1.2
        
        
            jstl
            jstl
            1.2
        
        
            javax.servlet
            servlet-api
            2.5
            provided
        
        
            com.oracle
            ojdbc6
            11.2.0.3
        
        
            com.alibaba
            fastjson
            1.2.8
        
    
    
    
        
            
                junit
                junit
                4.9
            
        
    
    
        
        
            
                org.apache.tomcat.maven
                tomcat7-maven-plugin
                
                    8888
                    /
                    
                    utf-8
                
            
        
    

erp_biz里面的pom.xml数据:



    
        erp_parent
        cn.wuyahui
        1.0-SNAPSHOT
    
    4.0.0

    cn.wuyahui
    erp_biz
    1.0-SNAPSHOT

    
    
        
            cn.wuyahui
            erp_dao
            1.0-SNAPSHOT
        
    

erp_dao里面的pom.xml数据:



    
        erp_parent
        cn.wuyahui
        1.0-SNAPSHOT
    
    4.0.0

    cn.wuyahui
    erp_dao
    1.0-SNAPSHOT

    
    
        
            cn.wuyahui
            erp_entity
            1.0-SNAPSHOT
        
        
            junit
            junit
            4.10
            test
        
    


erp_entity里面的pom.xml数据:



    
        erp_parent
        cn.wuyahui
        1.0-SNAPSHOT
    
    4.0.0

    cn.wuyahui
    erp_entity
    1.0-SNAPSHOT

erp_web里面的pom.xml数据:



    
        erp_parent
        cn.wuyahui
        1.0-SNAPSHOT
    
    4.0.0

    cn.wuyahui
    erp_web
    1.0-SNAPSHOT
    war
    
    
        
            cn.wuyahui
            erp_biz
            1.0-SNAPSHOT
        
    


接下来就是访问数据库操作了
IDEA maven项目中多个项目之间的依赖加web项目_第21张图片
IDEA maven项目中多个项目之间的依赖加web项目_第22张图片
IDEA maven项目中多个项目之间的依赖加web项目_第23张图片
接下来就是erp_dao:
IDEA maven项目中多个项目之间的依赖加web项目_第24张图片
dao层接口
IDEA maven项目中多个项目之间的依赖加web项目_第25张图片
dao层实现类
IDEA maven项目中多个项目之间的依赖加web项目_第26张图片
切记from Dep一定要跟实体类一致
IDEA maven项目中多个项目之间的依赖加web项目_第27张图片
代码如下:




		
			
		


IDEA maven项目中多个项目之间的依赖加web项目_第28张图片代码如下:


  
	
	
	
	
		
		
		
		
	
	
	
	
		
		
			
				org.hibernate.dialect.Oracle10gDialect
				true
				false
			
		
		
			classpath:/cn.wuyahui.erp.entity/Dep.hbm.xml
		
	

接下来测试一下从数据访问到的数据值:
IDEA maven项目中多个项目之间的依赖加web项目_第29张图片
IDEA maven项目中多个项目之间的依赖加web项目_第30张图片
这里就创建完成,我们来测试一下
IDEA maven项目中多个项目之间的依赖加web项目_第31张图片
结果如下:14个数据值(我的数据库里有14个值)
IDEA maven项目中多个项目之间的依赖加web项目_第32张图片
数据库表献上:

create table DEP  (
   UUID                 NUMBER                          not null,
   NAME                 VARCHAR2(30),
   TELE                 VARCHAR2(30),
   constraint PK_DEP primary key (UUID)
);

表里面的值就自己随便填多少个都可以,在此全部完结,不懂可以联系我

你可能感兴趣的:(java,ssh,idea)