ssh 连多个oracle数据库,IDEA maven项目中多个项目之间的依赖加web项目(带数据连接oracle ssh)转载请附上原地址谢谢!...

本文详细介绍了如何使用Maven创建一个包含父项目和多个子项目的多模块项目,包括erp_biz,erp_dao,erp_entity和erp_web。每个子项目的依赖关系被配置,例如erp_biz依赖erp_dao,erp_web依赖erp_biz。同时,展示了相关的Spring、Hibernate和Struts等技术的配置。最后,提到了数据库操作和DAO层的实现,以及测试数据的展示。
摘要由CSDN通过智能技术生成

首先让我们看整体的框架结构:

5a3f08ee399d

接下来,我们先创建一个父类项目(pom类型的)

![在这里我直接进行下一步操作]

5a3f08ee399d

5a3f08ee399d

5a3f08ee399d

创建好了父项目是这样的

5a3f08ee399d

erp_parent里面的pom.xml是这样的

5a3f08ee399d

接下来去创建子项目分别是:erp_biz,erp_dao,erp_entity,erp_web

5a3f08ee399d

5a3f08ee399d

下一步

5a3f08ee399d

下一步

5a3f08ee399d

erp_biz里面的pom.xml初始数据是:

5a3f08ee399d

这样我们第一个子项目就创建好了,其他几个同上(erp_web)注意他的打包方式是web包,我继续为大家搭建一下(erp_web子项目)。

5a3f08ee399d

按照我的指示一步步下来即可

5a3f08ee399d

5a3f08ee399d

5a3f08ee399d

创建所以项目完成后的样子

5a3f08ee399d

接下来,我们现在要做的是关联个个项目的依赖关系

5a3f08ee399d

5a3f08ee399d

5a3f08ee399d

5a3f08ee399d

其他的一样erp_biz依赖erp_dao,erp_web依赖erp_biz方法同上

献上全部代码:

erp_parent里面的pom.xml数据:

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">

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数据:

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">

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数据:

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">

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数据:

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">

erp_parent

cn.wuyahui

1.0-SNAPSHOT

4.0.0

cn.wuyahui

erp_entity

1.0-SNAPSHOT

erp_web里面的pom.xml数据:

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">

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

接下来就是访问数据库操作了

5a3f08ee399d

5a3f08ee399d

5a3f08ee399d

接下来就是erp_dao:

5a3f08ee399d

dao层接口

5a3f08ee399d

dao层实现类

5a3f08ee399d

切记from Dep一定要跟实体类一致

5a3f08ee399d

代码如下:

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xmlns:context="http://www.springframework.org/schema/context"

xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"

xsi:schemaLocation="

http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans.xsd

http://www.springframework.org/schema/context

http://www.springframework.org/schema/context/spring-context.xsd

http://www.springframework.org/schema/tx

http://www.springframework.org/schema/tx/spring-tx.xsd

http://www.springframework.org/schema/aop

http://www.springframework.org/schema/aop/spring-aop.xsd">

代码如下:

5a3f08ee399d

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"

xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"

xsi:schemaLocation="

http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans.xsd

http://www.springframework.org/schema/context

http://www.springframework.org/schema/context/spring-context.xsd

http://www.springframework.org/schema/tx

http://www.springframework.org/schema/tx/spring-tx.xsd

http://www.springframework.org/schema/aop

http://www.springframework.org/schema/aop/spring-aop.xsd

">

org.hibernate.dialect.Oracle10gDialect

true

false

classpath:/cn.wuyahui.erp.entity/Dep.hbm.xml

接下来测试一下从数据访问到的数据值:

5a3f08ee399d

5a3f08ee399d

这里就创建完成,我们来测试一下

5a3f08ee399d

结果如下:14个数据值(我的数据库里有14个值)

5a3f08ee399d

数据库表献上:

create table DEP  (

UUID                NUMBER                          not null,

NAME                VARCHAR2(30),

TELE                VARCHAR2(30),

constraint PK_DEP primary key (UUID)

);

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值