intelliJ idea创建分层的项目结构
来源:互联网 发布:移动网络了解 编辑:程序博客网 时间:2024/04/29 18:20
原文地址:http://yanwushu.sinaapp.com/create_layered_project_in_idea/
本文使用intelliJ idea 14
在idea中创建一个分层(视图层、业务逻辑层、数据访问层)的项目步骤如下:
创建一个project,idea在创建project的时候会默认创建一个module,此时,给这个project和module命名(比如hello_client,表示这是项目的客户端也就是视图层),并且指定项目存放路径。
新建一个module,新建的时候路径指定为和上面的hello_client同级。命名为hello_service,表明这是项目的业务逻辑层。
新建一个module,命名为hello_dal,表示这是项目的数据访问层,同上,此module的目录指定为和hello_client、hello_service同级。
此时在project窗口中会看到并列的三个module。开发的时候就可以在不同的层次上放置不同的代码。如下图:
图:三个同级的module代表项目中的三个不同层在项目中hello_client会引用hello_service的代码,而hello_service会引用hello_dal的代码。在idea中添加引用的方式为:
a) 选中任意一个module,按F4进入project structure;
b) 选择左侧的modules菜单;
c) 选择中间的hello_client,选中右侧的dependencies选项卡,点击右侧的绿色+按钮,选择modeule dependecy,在弹出的选择框中选择hello_service。
d) 这样就为hello_client添加了hello_service的引用。直接在hello_client中引用hello_service的代码即可。
e) 同理,添加hello_service对hello_dal的引用。
图:hello_client添加对hello_service的引用
- intelliJ idea创建分层的项目结构
- intelliJ idea创建分层的项目结构
- intelliJ idea创建分层的项目结构
- IntelliJ IDEA 创建项目
- Intellij Idea 创建项目
- IntelliJ idea下的项目结构
- intellij idea创建kotlin项目遇到的项目结构不全的解决办法
- Intellij idea+maven创建项目
- Intellij Idea 创建JavaWeb项目
- Intellij Idea 创建JavaWeb项目
- IntelliJ IDEA创建 SBT项目
- IntelliJ IDEA 创建Java项目
- Intellij IDEA创建maven项目
- Intellij Idea 创建JavaWeb项目
- IntelliJ IDEA创建项目技巧
- IntelliJ IDEA 创建Web项目
- IntelliJ IDEA 创建Web项目
- Intellij Idea创建Android项目
- Spring中配置获取HttpServletRequest的环境
- UvaLive 4254 Processor 优先队列
- Git 修订版本
- Android高手进阶教程(二十二)之---Android中几种图像特效处理的集锦!!
- 如何选择机器学习算法
- intelliJ idea创建分层的项目结构
- io.js和node.js怎么了?
- Tomcat 7.0 web.xml配置技巧
- 2、centos配置联网
- iOS8
- fork vfork clone
- Hive安装实践
- IOS学习笔记29—提示框第三方库之MBProgressHUD
- 学编程5点忌讳