IDEA & Maven & Spring & MyBatis 编写数据服务
2016-03-14 23:59
507 查看
Maven的webapp工程目录
IDEA 中的项目截图
忽视那个temptest文件夹
使用 Maven创建webapp
1.创建项目,选择Maven,模板选择 webapp2.填写相关的信息
说明:maven是以
groupId artifactId packaging version来唯一标识一个项目的。
- groupId:用来标识团体,公司,小组,组织,项目,或者其它团体,一般以逆向域名开头。
org.apache
- artifactId:项目的唯一标识符,不需要
.,比如
tomcat
- packaging: 标识项目的类型,如
jar,war等。
- version :版本号
3.选择maven的相关信息
4.项目名称及位置
5.创建完成后的工程目录
6.分别创建文件夹,其中,
test与
main平行,在
main下创建
Java文件夹,在
test文件夹下创建
java文件夹和
resources文件夹.
7.选中项目,F12,进入项目设置页面。
在该页面中,将
main/java标识为
Sources,
main/resources标识为
Resources,将
test/java标识为
Tests,将
test/resources标识为
Test Resources。
之前由于test文件夹标识错误,导致扫描不到包,报错找不到bean
添加spring及web支持
在pom.xml中添加相关的依赖,在resources文件夹下创建config文件夹,编写application-context.xml
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> <!-- 配置 要扫描的包--> <mvc:annotation-driven/> <context:component-scan base-package="com.fengtang.dataservice"/> <!-- 配置其他的配置文件 --> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>classpath:/config/other/db.properties</value> <value>classpath:/config/other/dubbo.properties</value> </list> </property> </bean> <!-- @Component and @Resource --> <bean class="org.springframework.context.annotation.CommonAnnotationBeanPostProcessor"/> </beans>
打开(Open Module Setting)页面,选中项目,F12
1.添加spring配置
点击
+,添加spring,然后,选中
application-context.xml
2.添加web配置
同样的操作
选中web.xml的路径
配置完毕。
maven打包
首先配置tomcat或者jetty环境然后build
3.在tomcat中部署
4.使用maven打包
相关文章推荐
- 学习笔记之2016_3_14---java的service domain dao 分层思路
- 多并发时支付如何保持账户余额的一致性?
- Myeclipse取消空格提示代码上屏
- [Java GC]Algorithm For GC
- java语法_3:IO
- Eclipse快捷键笔记
- Java Executor并发框架(一)整体介绍
- java语法_2:异常处理
- MyEclipse 中设置分割线,让代码更加规范。
- 如何配置Java环境变量
- java集群介绍
- Jump Game II | Java最短代码实现
- Java Socket编程
- JAVA类加载机制
- JavaWeb
- android studio 快捷键更改为和eclipse一样
- 网店系统javashop发布其开源框架,遵循GPL协议
- Spring中Resource实现类
- 5个强大的Java分布式缓存框架推荐
- Java线程并发控制基础知识