1. 1. 什么是maven?
  2. 它是一个软件开发的管理工具,主要管理的工作是:依赖管理,项目构建.
  3. 2. 使用maven的好处?
  4. 能够集中管理jar包,提供一键构建.
  5. 3. maven的安装及配置
  6. 配置:MAVEN_HOME,PATH路径配置.
  7. 本地仓库 : <localRepository>
  8. Settings.xml 文件中.
  9. <localRepository>d:/repository</..>
  10. 运行 : mvn -v.
  11. 4. 常用的maven命令
  12. compile,test,package,install,deploy
  13. clean
  14. site
  15. 5. maven 工程是具有一定的目录结构
  16. src
  17. main
  18. java(程序主要代码)
  19. resources(配置文件)
  20. webapps
  21. test
  22. java(测试代码)
  23. resources(测试的配置文件)
  24. pom.xml(写一些坐标)
  25. 6. eclipse工具下的maven工程开发
  26. 7. pom.xml文件中如何引入坐标
  27. <dependency>
  28. <groupId>javax.servlet</groupId>
  29. <artifactId>servlet-api</artifactId>
  30. <version>2.5</version>
  31. <scope>provided</scope>
  32. </dependency>
  33. 8. 总结
  34. 二、Maven工程的拆分与聚合(重点)
  35. 一个完整的早期开发好的crm项目,现在要使用maven工程对它进行拆分,这时候就可以将dao拆解出来形成表现独立的工程,同样service,action也都这样拆分
  36.  
  37. 工程拆分之后,将来还要聚合(聚合就是将拆分的工程进一步组合在一起,又形成一个完整的项目)
  38. 为了达到聚合的目标,所以今天会引入
  39. 父工程(maven project
  40. 子模块(maven module) dao ,service, web
  41.  
  42. 开发步骤:
  43. 1.创建一个maven父工程
  44.  
  45. 点下一步:
  46.  
  47. 创建后的父工程如下:
  48.  
  49. 从它的目录结构可以看出,父工程本身不写代码,它里面有一个pom.xml文件,这个文件可以将多个子模块中通用的jar所对应的坐标,集中在父工程中配置,将来的子模块就可以不需要在pom.xml中配置通用jar的坐标了
  50. 2.如何创建这个父工程的一个子模块?
  51.  
  52. next,进入如下图:
  53.  
  54. next,进入如下图:
  55.  
  56. 3.再次查看父工程的pom.xml文件
  57.  
  58. 4.查看子模块的pom.xml,发现多了一个 parent结点
  59.  
  60. 并且内部所包含的结点,其实就是父工程的坐标
  61. 坐标=groupId+artifactId+version
  62. 组织名 项目名 版本
  63. 三.冲突问题的解决
  64. 1.通过添加<exclusion>标签来解决冲突
  65. 在父工程中引入了struts-core,hibernate-core,就发现jar包是有冲突的
  66. Javassist存在版本上冲突问题
  67.  
  68. 进入下图:
  69.  
  70. 背后的父工程的pom.xml文件中,添加的内容
  71.  
  72. 2.依赖调解原则:
  73. maven自动按照下边的原则调解:
  74. 1、第一声明者优先原则
  75. pom文件定义依赖,先声明的依赖为准。
  76.  
  77. 测试:
  78. 如果将上边struts-spring-pluginsspring-context顺序颠倒,系统将导入spring-beans-4.2.4
  79. 分析:
  80. 由于spring-context在前边以spring-context依赖的spring-beans-4.2.4为准,所以最终spring-beans-4.2.4添加到了工程中。
  81.  
  82. 2、路径近者优先原则
  83. 例如:A依赖 spirng-beans-4.2.4A依赖B依赖 spirng-beans-3.0.5,则spring-beans-4.2.4优先被依赖在A中,因为spring-beans-4.2.4相对spirng-beans-3.0.5A依赖的路径最近。
  84. 测试:
  85. 在本工程中的pom中加入spirng-beans-4.2.4的依赖,根据路径近者优先原则,系统将导入spirng-beans-4.2.4
  86.  
  87. <dependency>
  88. <groupId>org.springframework</groupId>
  89. <artifactId>spring-beans</artifactId>
  90. <version>4.2.4.RELEASE</version>
  91. </dependency>
  92.  
  93. 2.使用版本锁定实现冲突解决
  94. 首先父工程中pom.xml文件添加:
  95.  
  96. 在使用坐标时,对于同一个框架,引入多次时,它的版本信息就会多次出现,所以
  97. 可以借用常量的思想,将这些版本号提取出来,在需要用到的时候,直接写版本的常量名称就可以了。
  98.  
  99. 引用上面的常量
  100.  
  101. 3.最终在ssh_parentpom.xml中引入的坐标
  102.  
  103. 依赖注入手动排除 : 可以当做特殊情况,struts2框架和hibernate框架很少使用共同的jar包.
  104. 声明优先原则 : 选择的依据,根据引入顺序,谁先引入,就先使用谁.
  105. pom.xml里面的Dependencies选项里面的坐标引入的都是直接依赖.
  106. 而通过直接依赖引入的jar包都是传递依赖.
  107. 路径近者优先 : 直接引入的依赖,优先级高于传递进来的依赖.
  108.  
  109. <!--使用常量来管理以后版本升级的问题 -->
  110. <properties>
  111. <spring-version>4.2.4RELEASE</spring-version>
  112. </properties>
  113. <!-- 依赖管理节点限制使用jar包的版本 -->
  114. <dependencyManagement>
  115. <dependencies>
  116. <dependency>
  117. <groupId>org.springframework</groupId>
  118. <artifactId>spring-context</artifactId>
  119. <version>${spring-version}</version>
  120. </dependen
  121. </dependencies>
  122. </dependcyManagement>
  123.  
  124. 三、依赖关系
  125. 依赖具有传递性,但不是无限传递的,传递的规则如下:
  126. A-provided-B B-runtime-C
  127.  
  128. 解决方法:
  129. 如果在依赖传递过程中,导致jar包丢失,我们的做法很简单,就是再导入一次坐标
  130.  
  131. 四.编写Service模块
  132. 1.创建一个maven module项目
  133. 创建结束后,父工程中结构如下:
  134.  
  135. 父工程的pom.xml文件如下
  136.  
  137. 2.servicepom.xml文件中引入daojar
  138.  
  139. Web层的子模块创建:
  140.  
  141. 四、私服搭建
  142. 下载nexus
  143.  
  144. Nexus Maven仓库管理器,通过nexus可以搭建maven仓库,同时nexus还提供强大的仓库管理功能,构件搜索功能等。
  145. 下载Nexus 下载地址:http://www.sonatype.org/nexus/archived/
  146.  
  147. 下载:nexus-2.12.0-01-bundle.zip
  148.  
  149. 安装
  150. 1.解压,进入指定的目录
  151.  
  152. 2.安装并启动这个应用程序
  153. cmd进入bin目录(E:\sshenv\nexus-2.12.0-01-bundle\nexus-2.12.0-01\bin),执行nexus.bat install
  154.  
  155. 安装成功在服务中查看有nexus服务:
  156.  
  157. 卸载nexus
  158. cmd进入nexusbin目录,执行:nexus.bat uninstall
  159.  
  160. 查看window服务列表nexus已被删除。
  161.  
  162. 启动nexus
  163. 方法1
  164. cmd进入bin(你解压的nexusbin)目录,执行nexus.bat start
  165. 方法2
  166. 直接启动nexus服务
  167.  
  168. 查看nexus的配置文件conf/nexus.properties
  169.  
  170. # Jetty section
  171. application-port=8081 # nexus的访问端口配置
  172. application-host=0.0.0.0 # nexus主机监听配置(不用修改)
  173. nexus-webapp=${bundleBasedir}/nexus # nexus工程目录
  174. nexus-webapp-context-path=/nexus # nexus的web访问路径
  175.  
  176. # Nexus section
  177. nexus-work=${bundleBasedir}/../sonatype-work/nexus # nexus仓库目录
  178. runtime=${bundleBasedir}/nexus/WEB-INF # nexus运行程序目录
  179.  
  180. 访问:
  181. http://localhost:8081/nexus/
  182. 使用Nexus 内置账户admin/admin123登陆:
  183. 点击右上角的Log in,输入账号和密码 登陆
  184.  
  185. 登陆成功:
  186.  
  187. nexus的仓库有4种类型:
  188.  
  189. 1.hosted,宿主仓库,部署自己的jar到这个类型的仓库,包括releasessnapshot两部分,Releases公司内部发布版本仓库、 Snapshots 公司内部测试版本仓库
  190.  
  191. 2.proxy,代理仓库,用于代理远程的公共仓库,如maven中央仓库,用户连接私服,私服自动去中央仓库下载jar包或者插件。
  192.  
  193. 3.group,仓库组,用来合并多个hosted/proxy仓库,通常我们配置自己的maven连接仓库组。
  194. 4.virtual(虚拟):兼容Maven1 版本的jar或者插件
  195. nexus仓库默认在sonatype-work目录中:
  196.  
  197. central:代理仓库,代理中央仓库
  198.  
  199. apache-snapshots:代理仓库
  200. 存储snapshots构件,代理地址https://repository.apache.org/snapshots/
  201. central-m1virtual类型仓库,兼容Maven1 版本的jar或者插件
  202. releases:本地仓库,存储releases构件。
  203. snapshots:本地仓库,存储snapshots构件。
  204. thirdparty:第三方仓库
  205. public:仓库组
  206.  
  207. 需求 :将ssh_dao的这个工程打成jar包,并放入到私服上去.
  208. 配置
  209. 第一步: 需要在客户端即部署dao工程的电脑上配置 maven环境,并修改 settings.xml 文件,配置连接私服的用户和密码
  210.  
  211. 此用户名和密码用于私服校验,因为私服需要知道上传的账号和密码 是否和私服中的账号和密码 一致。
  212.  
  213. <server>
  214. <id>releases</id>
  215. <username>admin</username>
  216. <password>admin123</password>
  217. </server>
  218. <server>
  219. <id>snapshots</id>
  220. <username>admin</username>
  221. <password>admin123</password>
  222. </server>
  223.  
  224. releases 连接发布版本项目仓库
  225. snapshots 连接测试版本项目仓库
  226.  
  227. 第二步: 配置项目pom.xml
  228.  
  229. 配置私服仓库的地址,本公司的自己的jar包会上传到私服的宿主仓库,根据工程的版本号决定上传到哪个宿主仓库,如果版本为release则上传到私服的release仓库,如果版本为snapshot则上传到私服的snapshot仓库
  230.  
  231. <distributionManagement>
  232. <repository>
  233. <id>releases</id>
  234. <url>http://localhost:8081/nexus/content/repositories/releases/</url>
  235. </repository>
  236. <snapshotRepository>
  237. <id>snapshots</id>
  238. <url>http://localhost:8081/nexus/content/repositories/snapshots/</url>
  239. </snapshotRepository>
  240. </distributionManagement>
  241.  
  242. 注意:pom.xml这里<id> settings.xml 配置 <id> 对应!
  243.  
  244. 测试
  245. 将项目dao工程打成jar包发布到私服:
  246. 1、首先启动nexus
  247. 2、对dao工程执行deploy命令
  248. 从私服下载jar
  249. 需求
  250. 没有配置nexus之前,如果本地仓库没有,去中央仓库下载,通常在企业中会在局域网内部署一台私服服务器,有了私服本地项目首先去本地仓库找jar,如果没有找到则连接私服从私服下载jar包,如果私服没有jar包私服同时作为代理服务器从中央仓库下载jar包,这样做的好处是一方面由私服对公司项目的依赖jar包统一管理,一方面提高下载速度,项目连接私服下载jar包的速度要比项目连接中央仓库的速度快的多。
  251.  
  252. 本例子测试从私服下载dao 工程jar包。
  253. 管理仓库组
  254. nexus中包括很多仓库,hosted中存放的是企业自己发布的jar包及第三方公司的jar包,proxy中存放的是中央仓库的jar,为了方便从私服下载jar包可以将多个仓库组成一个仓库组,每个工程需要连接私服的仓库组下载jar包。
  255.  
  256. 打开nexus配置仓库组,如下图:
  257.  
  258. 上图中仓库组包括了本地仓库、代理仓库等。
  259.  
  260. setting.xml中配置仓库
  261. 在客户端的setting.xml中配置私服的仓库,由于setting.xml中没有repositories的配置标签需要使用profile定义仓库。
  262.  
  263. <profile>
  264. <!--profileid-->
  265. <id>dev</id>
  266. <repositories>
  267. <repository>
  268. <!--仓库idrepositories可以配置多个仓库,保证id不重复-->
  269. <id>nexus</id>
  270. <!--仓库地址,即nexus仓库组的地址-->
  271. <url>http://localhost:8081/nexus/content/groups/public/</url>
  272. <!--是否下载releases构件-->
  273. <releases>
  274. <enabled>true</enabled>
  275. </releases>
  276. <!--是否下载snapshots构件-->
  277. <snapshots>
  278. <enabled>true</enabled>
  279. </snapshots>
  280. </repository>
  281. </repositories>
  282. <pluginRepositories>
  283. <!-- 插件仓库,maven的运行依赖插件,也需要从私服下载插件 -->
  284. <pluginRepository>
  285. <!-- 插件仓库的id不允许重复,如果重复后边配置会覆盖前边 -->
  286. <id>public</id>
  287. <name>Public Repositories</name>
  288. <url>http://localhost:8081/nexus/content/groups/public/</url>
  289. </pluginRepository>
  290. </pluginRepositories>
  291. </profile>
  292.  
  293. 使用profile定义仓库需要激活才可生效。
  294.  
  295. <activeProfiles>
  296. <activeProfile>dev</activeProfile>
  297. </activeProfiles>
  298.  
  299. 配置成功后通过eclipse查看有效pom,有效pommaven软件最终使用的pom内容,程序员不直接编辑有效pom,打开有效pom
  300.  
  301. 有效pom内容如下:
  302. 下边的pom内容中有两个仓库地址,maven会先从前边的仓库的找,如果找不到jar包再从下边的找,从而就实现了从私服下载jar包。
  303. <repositories>
  304. <repository>
  305. <releases>
  306. <enabled>true</enabled>
  307. </releases>
  308. <snapshots>
  309. <enabled>true</enabled>
  310. </snapshots>
  311. <id>public</id>
  312. <name>Public Repositories</name>
  313. <url>http://localhost:8081/nexus/content/groups/public/</url>
  314. </repository>
  315. <repository>
  316. <snapshots>
  317. <enabled>false</enabled>
  318. </snapshots>
  319. <id>central</id>
  320. <name>Central Repository</name>
  321. <url>https://repo.maven.apache.org/maven2</url>
  322. </repository>
  323. </repositories>
  324. <pluginRepositories>
  325. <pluginRepository>
  326. <id>public</id>
  327. <name>Public Repositories</name>
  328. <url>http://localhost:8081/nexus/content/groups/public/</url>
  329. </pluginRepository>
  330. <pluginRepository>
  331. <releases>
  332. <updatePolicy>never</updatePolicy>
  333. </releases>
  334. <snapshots>
  335. <enabled>false</enabled>
  336. </snapshots>
  337. <id>central</id>
  338. <name>Central Repository</name>
  339. <url>https://repo.maven.apache.org/maven2</url>
  340. </pluginRepository>
  341. </pluginRepositories>
  342.  
  343. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  344. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  345. <modelVersion>4.0.0</modelVersion>
  346. <groupId>cn.baidu.maven</groupId>
  347. <artifactId>maven-crm</artifactId>
  348. <version>0.0.1-SNAPSHOT</version>
  349. <packaging>war</packaging>
  350. <name>web工程,包括jspaction等</name>
  351. <description>web工程,包括jspaction等</description>
  352.  
  353. <!-- 为了确定每个框架的版本号 -->
  354.  
  355. <!-- 锁定版本 -->
  356. <properties>
  357. <spring.version>4.2.4.RELEASE</spring.version>
  358. <struts2.version>2.3.24</struts2.version>
  359. <hibernate.version>5.0.7.Final</hibernate.version>
  360. <slf4j.version>1.6.6</slf4j.version>
  361. <log4j.version>1.2.12</log4j.version>
  362. <shiro.version>1.2.3</shiro.version>
  363. <cxf.version>3.0.1</cxf.version>
  364. <c3p0.version>0.9.1.2</c3p0.version>
  365. <mysql.version>5.1.6</mysql.version>
  366. </properties>
  367. <!-- 锁定版本,struts2-2.3.24spring4.2.4hibernate5.0.7 -->
  368. <dependencyManagement>
  369. <dependencies>
  370. <dependency>
  371. <groupId>org.springframework</groupId>
  372. <artifactId>spring-context</artifactId>
  373. <version>${spring.version}</version>
  374. </dependency>
  375. <dependency>
  376. <groupId>org.springframework</groupId>
  377. <artifactId>spring-aspects</artifactId>
  378. <version>${spring.version}</version>
  379. </dependency>
  380. <dependency>
  381. <groupId>org.springframework</groupId>
  382. <artifactId>spring-orm</artifactId>
  383. <version>${spring.version}</version>
  384. </dependency>
  385. <dependency>
  386. <groupId>org.springframework</groupId>
  387. <artifactId>spring-test</artifactId>
  388. <version>${spring.version}</version>
  389. </dependency>
  390. <dependency>
  391. <groupId>org.springframework</groupId>
  392. <artifactId>spring-web</artifactId>
  393. <version>${spring.version}</version>
  394. </dependency>
  395. <dependency>
  396. <groupId>org.hibernate</groupId>
  397. <artifactId>hibernate-core</artifactId>
  398. <version>${hibernate.version}</version>
  399. </dependency>
  400. <dependency>
  401. <groupId>org.apache.struts</groupId>
  402. <artifactId>struts2-core</artifactId>
  403. <version>${struts2.version}</version>
  404. </dependency>
  405. <dependency>
  406. <groupId>org.apache.struts</groupId>
  407. <artifactId>struts2-spring-plugin</artifactId>
  408. <version>${struts2.version}</version>
  409. </dependency>
  410.  
  411. </dependencies>
  412. </dependencyManagement>
  413.  
  414. <dependencies>
  415. <dependency>
  416. <groupId>org.apache.httpcomponents</groupId>
  417. <artifactId>httpclient</artifactId>
  418. <version>4.4</version>
  419. </dependency>
  420. <dependency>
  421. <groupId>com.alibaba</groupId>
  422. <artifactId>fastjson</artifactId>
  423. <version>1.1.37</version>
  424. </dependency>
  425. <dependency>
  426. <groupId>commons-beanutils</groupId>
  427. <artifactId>commons-beanutils</artifactId>
  428. <version>1.9.1</version>
  429. </dependency>
  430. <!-- <dependency>
  431. <groupId>org.quartz-scheduler</groupId>
  432. <artifactId>quartz</artifactId>
  433. <version>2.2.1</version>
  434. </dependency> -->
  435. <dependency>
  436. <groupId>commons-fileupload</groupId>
  437. <artifactId>commons-fileupload</artifactId>
  438. <version>1.3.1</version>
  439. </dependency>
  440.  
  441. <!-- jstl -->
  442. <dependency>
  443. <groupId>jstl</groupId>
  444. <artifactId>jstl</artifactId>
  445. <version>1.2</version>
  446. </dependency>
  447.  
  448. <!-- shiro -->
  449. <!-- apache shiro dependencies -->
  450. <!-- <dependency>
  451. <groupId>org.apache.shiro</groupId>
  452. <artifactId>shiro-all</artifactId>
  453. <version>${shiro.version}</version>
  454. </dependency> -->
  455.  
  456. <!-- spring -->
  457. <dependency>
  458. <groupId>org.aspectj</groupId>
  459. <artifactId>aspectjweaver</artifactId>
  460. <version>1.6.8</version>
  461. </dependency>
  462.  
  463. <dependency>
  464. <groupId>org.springframework</groupId>
  465. <artifactId>spring-aop</artifactId>
  466. <version>${spring.version}</version>
  467. </dependency>
  468.  
  469. <dependency>
  470. <groupId>org.springframework</groupId>
  471. <artifactId>spring-context</artifactId>
  472. <version>${spring.version}</version>
  473. </dependency>
  474.  
  475. <dependency>
  476. <groupId>org.springframework</groupId>
  477. <artifactId>spring-context-support</artifactId>
  478. <version>${spring.version}</version>
  479. </dependency>
  480.  
  481. <dependency>
  482. <groupId>org.springframework</groupId>
  483. <artifactId>spring-web</artifactId>
  484. <version>${spring.version}</version>
  485. </dependency>
  486.  
  487. <dependency>
  488. <groupId>org.springframework</groupId>
  489. <artifactId>spring-orm</artifactId>
  490. <version>${spring.version}</version>
  491. </dependency>
  492.  
  493. <dependency>
  494. <groupId>org.springframework</groupId>
  495. <artifactId>spring-beans</artifactId>
  496. <version>${spring.version}</version>
  497. </dependency>
  498.  
  499. <dependency>
  500. <groupId>org.springframework</groupId>
  501. <artifactId>spring-core</artifactId>
  502. <version>${spring.version}</version>
  503. </dependency>
  504.  
  505. <!-- struts2 begin -->
  506. <dependency>
  507. <groupId>org.apache.struts</groupId>
  508. <artifactId>struts2-core</artifactId>
  509. <version>${struts2.version}</version>
  510. <exclusions>
  511. <exclusion>
  512. <artifactId>javassist</artifactId>
  513. <groupId>javassist</groupId>
  514. </exclusion>
  515. </exclusions>
  516. </dependency>
  517. <dependency>
  518. <groupId>org.apache.struts</groupId>
  519. <artifactId>struts2-spring-plugin</artifactId>
  520. <version>${struts2.version}</version>
  521. </dependency>
  522. <dependency>
  523. <groupId>org.apache.struts</groupId>
  524. <artifactId>struts2-json-plugin</artifactId>
  525. <version>${struts2.version}</version>
  526. </dependency>
  527. <dependency>
  528. <groupId>org.apache.struts</groupId>
  529. <artifactId>struts2-convention-plugin</artifactId>
  530. <version>${struts2.version}</version>
  531. </dependency>
  532. <!-- struts2 end -->
  533.  
  534. <!-- hibernate begin -->
  535. <dependency>
  536. <groupId>org.hibernate</groupId>
  537. <artifactId>hibernate-core</artifactId>
  538. <version>${hibernate.version}</version>
  539. </dependency>
  540. <dependency>
  541. <groupId>org.hibernate</groupId>
  542. <artifactId>hibernate-entitymanager</artifactId>
  543. <version>${hibernate.version}</version>
  544. </dependency>
  545. <dependency>
  546. <groupId>org.hibernate</groupId>
  547. <artifactId>hibernate-validator</artifactId>
  548. <version>5.2.1.Final</version>
  549. </dependency>
  550. <!-- hibernate end -->
  551.  
  552. <dependency>
  553. <groupId>c3p0</groupId>
  554. <artifactId>c3p0</artifactId>
  555. <version>${c3p0.version}</version>
  556. </dependency>
  557.  
  558. <!-- <dependency>
  559. <groupId>org.apache.cxf</groupId>
  560. <artifactId>cxf-rt-frontend-jaxws</artifactId>
  561. <version>${cxf.version}</version>
  562. </dependency>
  563. <dependency>
  564. <groupId>org.apache.cxf</groupId>
  565. <artifactId>cxf-rt-transports-http</artifactId>
  566. <version>${cxf.version}</version>
  567. </dependency> -->
  568.  
  569. <!-- log start -->
  570. <dependency>
  571. <groupId>log4j</groupId>
  572. <artifactId>log4j</artifactId>
  573. <version>${log4j.version}</version>
  574. </dependency>
  575.  
  576. <dependency>
  577. <groupId>org.slf4j</groupId>
  578. <artifactId>slf4j-api</artifactId>
  579. <version>${slf4j.version}</version>
  580. </dependency>
  581.  
  582. <dependency>
  583. <groupId>org.slf4j</groupId>
  584. <artifactId>slf4j-log4j12</artifactId>
  585. <version>${slf4j.version}</version>
  586. </dependency>
  587. <!-- log end -->
  588.  
  589. <!-- Javamail -->
  590. <!-- <dependency>
  591. <groupId>javax.mail</groupId>
  592. <artifactId>mail</artifactId>
  593. <version>1.4.4</version>
  594. </dependency> -->
  595.  
  596. <dependency>
  597. <groupId>commons-lang</groupId>
  598. <artifactId>commons-lang</artifactId>
  599. <version>2.6</version>
  600. </dependency>
  601.  
  602. <!-- <dependency>
  603. <groupId>org.codehaus.xfire</groupId>
  604. <artifactId>xfire-core</artifactId>
  605. <version>1.2.6</version>
  606. </dependency> -->
  607.  
  608. <dependency>
  609. <groupId>dom4j</groupId>
  610. <artifactId>dom4j</artifactId>
  611. <version>1.6</version>
  612. </dependency>
  613.  
  614. <!-- <dependency>
  615. <groupId>org.apache.poi</groupId>
  616. <artifactId>poi</artifactId>
  617. <version>3.11</version>
  618. </dependency>
  619. <dependency>
  620. <groupId>org.apache.poi</groupId>
  621. <artifactId>poi-ooxml</artifactId>
  622. <version>3.11</version>
  623. </dependency>
  624. <dependency>
  625. <groupId>org.apache.poi</groupId>
  626. <artifactId>poi-ooxml-schemas</artifactId>
  627. <version>3.11</version>
  628. </dependency> -->
  629.  
  630. <dependency>
  631. <groupId>mysql</groupId>
  632. <artifactId>mysql-connector-java</artifactId>
  633. <version>${mysql.version}</version>
  634. </dependency>
  635. <!-- <dependency>
  636. <groupId>com.oracle</groupId>
  637. <artifactId>ojdbc14</artifactId>
  638. <version>10.2.0.4.0</version>
  639. </dependency> -->
  640. <dependency>
  641. <groupId>javax.servlet</groupId>
  642. <artifactId>servlet-api</artifactId>
  643. <version>2.5</version>
  644. <scope>provided</scope>
  645. </dependency>
  646. <dependency>
  647. <groupId>javax.servlet.jsp</groupId>
  648. <artifactId>jsp-api</artifactId>
  649. <version>2.0</version>
  650. <scope>provided</scope>
  651. </dependency>
  652. <dependency>
  653. <groupId>net.sf.ehcache</groupId>
  654. <artifactId>ehcache-core</artifactId>
  655. <version>2.6.6</version>
  656. </dependency>
  657. </dependencies>
  658.  
  659. <build>
  660.  
  661. <pluginManagement>
  662. <plugins>
  663. <plugin>
  664. <groupId>org.apache.maven.plugins</groupId>
  665. <artifactId>maven-compiler-plugin</artifactId>
  666. <version>3.2</version>
  667. <configuration>
  668. <source>1.7</source>
  669. <target>1.7</target>
  670. <encoding>UTF-8</encoding>
  671. <showWarnings>true</showWarnings>
  672. </configuration>
  673. </plugin>
  674. </plugins>
  675. </pluginManagement>
  676. </build>
  677.  
  678. <!-- parnet节点指定子模块的 父工程的坐标信息 -->
  679. <parent>
  680. <groupId>cn.baidu</groupId>
  681. <artifactId>ssh_maven</artifactId>
  682. <version>0.0.1-SNAPSHOT</version>
  683. </parent>
  684.  
  685. <artifactId>ssh_dao</artifactId>
  686.  
  687. <dependencies>
  688. <dependency>
  689. <groupId>junit</groupId>
  690. <artifactId>junit</artifactId>
  691. <version>4.10</version>
  692. <scope>test</scope>
  693. </dependency>
  694. </dependencies>
  695. <!-- 上传jar包使用命令 deploey部署到私服 后本地仓库会不会有 -->
  696. <distributionManagement>
  697. <repository>
  698. <id>releases</id>
  699. <url>http://localhost:8081/nexus/content/repositories/releases/</url>
  700. </repository>
  701. <snapshotRepository>
  702. <id>snapshots</id>
  703. <url>http://localhost:8081/nexus/content/repositories/snapshots/</url>
  704. </snapshotRepository>
  705. </distributionManagement>
  706.  
  707. </project>
  708.  
  709. applicationContext-dao.xml
  710. <?xml version="1.0" encoding="UTF-8"?>
  711. <beans xmlns="http://www.springframework.org/schema/beans"
  712. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
  713. xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
  714. xsi:schemaLocation="
  715. http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
  716. http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
  717. http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
  718. http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd">
  719. <!-- dataSource数据源 -->
  720. <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
  721. <property name="driverClass" value="com.mysql.jdbc.Driver"></property>
  722. <property name="jdbcUrl" value="jdbc:mysql:///maven_ssh"></property>
  723. <property name="user" value="root"></property>
  724. <property name="password" value="root"></property>
  725. </bean>
  726. <!-- seesionFactory -->
  727. <bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
  728. <!-- 数据源 -->
  729. <property name="dataSource" ref="dataSource"></property>
  730. <!-- hibernate的配置 --><!-- 实体类映射 -->
  731. <property name="configLocations" value="classpath:hibernate.cfg.xml"></property>
  732. </bean>
  733. <!-- 事务的管理器 -->
  734. <bean id="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager">
  735. <property name="sessionFactory" ref="sessionFactory"></property>
  736. </bean>
  737. <!-- 事务的通知 -->
  738. <tx:advice id="txAdvice" >
  739. <tx:attributes>
  740. <tx:method name="save*" propagation="REQUIRED"/>
  741. <tx:method name="update*" propagation="REQUIRED"/>
  742. <tx:method name="delete*" propagation="REQUIRED"/>
  743. <tx:method name="find*" read-only="true"/>
  744. </tx:attributes>
  745. </tx:advice>
  746. <!-- 切面配置 -->
  747. <aop:config>
  748. <!-- 切入点配置 -->
  749. <aop:pointcut expression="execution(* cn.baidu.service.*.*(..))" id="pointcut"/>
  750. <aop:advisor advice-ref="txAdvice" pointcut-ref="pointcut"/>
  751. </aop:config>
  752. <!-- 自己的持久层dao -->
  753. <bean id="customerDao" class="cn.baidu.dao.impl.CustomerDaoImpl">
  754. <property name="sessionFactory" ref="sessionFactory"></property>
  755. </bean>
  756.  
  757. </beans>

maven仓库之第二篇的更多相关文章

  1. maven仓库之第一篇

    maven jar仓库 :存放maven项目使用的jar包. 中央仓库,存放99%免费开源项目jar包,apache公司负责维护的,以T为单位的存储. 例如 : struts2-core-2.3.24 ...

  2. 【第六篇】- Maven 仓库之Spring Cloud直播商城 b2b2c电子商务技术总结

    Maven 仓库 在 Maven 的术语中,仓库是一个位置(place). Maven 仓库是项目中依赖的第三方库,这个库所在的位置叫做仓库. 在 Maven 中,任何一个依赖.插件或者项目构建的输出 ...

  3. 【第二篇】- Maven 环境配置之Spring Cloud直播商城 b2b2c电子商务技术总结

    Maven 环境配置 Maven 是一个基于 Java 的工具,所以要做的第一件事情就是安装 JDK. 如果你还未安装 JDK,可以参考我们的 Java 开发环境配置. 系统要求 项目 要求 JDK ...

  4. 拥抱 Android Studio 之四:Maven 仓库使用与私有仓库搭建

    使用.创造和分享 笔者曾经不思量力的思考过『是什么推动了互联网技术的快速发展?』这种伟大的命题.结论是,除了摩尔定律之外,技术经验的快速积累和广泛分享,也是重要的原因. 有人戏称,『写 Java,首先 ...

  5. N使用exus2打造企业maven仓库(三)

    假设项目中,我没有使用maven,我应该做出选择,或为项目.或者用它来推动这个项目从maven.有人会问,为什么maven?无需maven我们没有很好的操作. 这里,只说两件事情我最欣赏:第一点是管理 ...

  6. Android studio Maven仓库使用

    原文:How to distribute your own Android library through jCenter and Maven Central from Android Studio ...

  7. Maven系列第8篇:你的maven项目构建太慢了,我实在看不下去,带你一起磨刀!!多数使用maven的人都经常想要的一种功能,但是大多数人都不知道如何使用!!!

    maven系列目标:从入门开始开始掌握一个高级开发所需要的maven技能. 这是maven系列第8篇. 整个maven系列的内容前后是有依赖的,如果之前没有接触过maven,建议从第一篇看起,本文尾部 ...

  8. maven仓库私服配置

    私服访问地址:[[http://192.168.1.252:9080/nexus/content/groups/public/ 地址]] 1. 打开eclipse/myeclipse的maven插件: ...

  9. RabbitMQ学习总结 第二篇:快速入门HelloWorld

    目录 RabbitMQ学习总结 第一篇:理论篇 RabbitMQ学习总结 第二篇:快速入门HelloWorld RabbitMQ学习总结 第三篇:工作队列Work Queue RabbitMQ学习总结 ...

随机推荐

  1. 学习Python编程技术的流程与步骤,自学与参加培训学习都适用

     一.清楚学习目标 无论是学习什么知识,都要有一个对学习目标的清楚认识.只有这样才能朝着目标持续前进,少走弯路,从学习中得到不断的提升,享受python学习计划的过程. 虽然目前的编程语言有很多,但是 ...

  2. 《大话设计模式》——简单工厂模式(Python版)

    简单工厂模式(Simple Factory Pattern):是通过专门定义一个类来负责创建其他类的实例,被创建的实例通常都具有共同的父类. 例: 使用Python设计一个控制台计算器,要求输入两个数 ...

  3. HttpRunner学习4--使用正则表达式提取数据

    前言 在HttpRunner中,我们可通过extract提取数据,当响应结果为 JSON 结构,可使用 content 结合 . 运算符的方式,如 content.code,用起来十分方便,但如果响应 ...

  4. 【后端C#】后台通过http post 调用 webservice 的方法

    定义http post 调用webservice的某个方法 /// <summary> /// http Post调用 WebService /// </summary> pu ...

  5. Android 再次打开APP进入按Home键退出时的界面(thisTaskRoot)

    问题 Android 设置页面的启动模式为 singletask 之后,当按Home 退出时,再重新打开应用,还会进入首启动页.就会造成一些应用需要重新登录,当前页数据丢失等问题 解决 去除启动页的 ...

  6. linux 定时备份数据库

    说明 检查Crontab是否安装 若没有 需要先安装Crontab定时工具 安装定时工具参考(https://www.cnblogs.com/shaohuixia/p/5577738.html) 需要 ...

  7. h5 Video打开本地摄像头和离开页面关闭摄像头

    <div> <video id="video" style="width=100%; height=100%; object-fit: fill&quo ...

  8. Java之封装与访问权限控制(一)

    目录 Java之封装与访问权限控制(一) 封装的概念 访问控制符 属性私有化 Java之封装与访问权限控制(一) 对于封装的概念,我总觉得自己还是挺了解的,但是真要我说,还真说不出个啥来.我只能默默地 ...

  9. 设置tomcat为自动启动

    第一步:设置tomcat为服务启动项 进入dos窗口,输入service.bat install,启动服务, 这里要注意的是,如果直接在cmd输入报错,需要你进入到tomcat的目录下执行cmd 第二 ...

  10. Python中Pyyaml模块的使用

    一.YAML是什么 YAML是专门用来写配置文件的语言,远比JSON格式方便. YAML语言的设计目标,就是方便人类读写. YAML是一种比XML和JSON更轻的文件格式,也更简单更强大,它可以通过缩 ...