Maven项目开发
来源:互联网 发布:ubuntu输入法设置 编辑:程序博客网 时间:2024/06/10 21:50
用Maven开发一个项目或者项目中的一个模块
1、首先确定开发工具以及环境例如: Eclipse4.4.1——luna -解压直接使用 Maven3.2.3 -解压并安装 Tomcat7(在maven中安装) -在pom.xml中配置
<plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <configuration> <port>8081</port> <path>/</path> </configuration> </plugin>
Mysql5.6
Nginx1.5.1
Redis2.8.9
Win7操作系统
SVN版本管理
2、购买一个域名
例:www.baidu.com
3、创建一个Maven项目
本次开发使用分布式系统架构多个服务器集群对数据库进行才做,用单点登录来维持登录状态。
所以在创建项目时考虑到本项目很可能会被其他模块调用,所以会把传统项目中的层级结构用maven项目的形式创建出来以方便打包,在其他项目中使用该项目的时候只需要导入依赖就可以使用。
本Maven项目分为
——父工程 XXX-parent(打包方式:pom)
其中集中定义依赖版本以及项目中用到的依赖
——通用工程 XXX-common(打包方式:jar)
定义项目中用到的通用部分
——管理工程 XXX-manage(打包方式:pom)
工程主体,聚合其他自工程
—以管理工程为父工程创建开发项目需要的子工程
XXX-manage-pojo-实体工程
XXX-manage-mapper-Mapper代理工程
XXX-manage-service-业务工程
XXX-manage-web-控制层工程(controller/action)–
-
各个工程之间存在依赖关系
web—>service—>mapper—>pojo
-
导入依赖的原则:
1、所有的工程都需要的依赖应该在聚合工程(taotao-manage)中导入。
2、在使用依赖的最底层导入。
3、运行时所需要的依赖在web工程中加入。
以ssm(spring+springMVC+Mybatis)为例
***在manage中需要导入***<!-- 单元测试 --> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>${junit.version}</version> <scope>test</scope> </dependency><!-- Apache工具组件 --> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-io</artifactId> </dependency>
***在通用Mapper中需要导入***<!-- 通用mapper --> <dependency> <groupId>com.github.abel533</groupId> <artifactId>mapper</artifactId> <!-- 排除JPA依赖,有taotao-manage-pojo传递JPA依赖 --> <exclusions> <exclusion> <artifactId>persistence-api</artifactId> <groupId>javax.persistence</groupId> </exclusion> </exclusions> </dependency>
***在pojo中需要导入***<!-- 用JPA注解使实体类与表关联 --><dependency> <groupId>javax.persistence</groupId> <artifactId>persistence-api</artifactId> <version>1.0</version> </dependency>
***在service中需要导入*** <!-- 分页工具 --> <dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper</artifactId> </dependency> <dependency> <groupId>com.github.jsqlparser</groupId> <artifactId>jsqlparser</artifactId> </dependency>
***在web中需要导入*** <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aspects</artifactId> </dependency> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis-spring</artifactId> </dependency> <!-- MySql --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> </dependency> <!-- Jackson Json处理工具包 --> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> </dependency> <!-- 连接池 --> <dependency> <groupId>com.jolbox</groupId> <artifactId>bonecp-spring</artifactId> </dependency> <!-- JSP相关 --> <dependency> <groupId>jstl</groupId> <artifactId>jstl</artifactId> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>jsp-api</artifactId> <scope>provided</scope> </dependency>
以上这样按需求配置所用的依赖是最合理的方法,不推荐使用继承父工程中的所有依赖
–最后根据框架创建web.xml
- maven开发web项目
- IDEA开发Maven项目
- Maven项目开发
- 使用Maven开发Java项目
- 项目开发之使用 maven
- java maven项目开发常识
- Maven开发多模块项目
- 在 IDEA 下开发 android maven 项目
- intellij IDEA开发工具项目maven管理
- 在eclipse下开发maven项目
- eclipse+maven+tomcat 开发web项目
- intellij IDEA开发工具项目maven管理
- maven myeclipse10 整合开发web项目-1
- maven myeclipse10 整合开发web项目-2
- maven myeclipse10 整合开发web项目-3
- 用maven管理hadoop开发项目
- eclipse下maven项目开发编译
- 使用idea开发maven项目遇到问题
- 阿里笔试和毕业论文
- Vue键盘事件
- 蓝桥杯 算法训练 乘积最大 dp
- java+selenium搭建环境
- GDOI2017模拟 第四场(4.24~4.26)
- Maven项目开发
- c#设计模式==抽象工厂模式
- 1019. 数字黑洞 (20)
- MEMORY主电源电压变化数据(VDD=VDDQ)
- 详解/etc/profile、/etc/bash.bahsrc、~/.profile、~/.bashrc的用途
- Linux入门3(手记)
- Python的基础——Python学习笔记02
- python-cookbook学习笔记七
- git学习总结系列(1)——基本用法