完整目录
导入创建maven工程目录的jar包
Demo
package com.itheima;
public class Demo {
public String say(String name){
System.out.println("hello"+name);
return "hello "+name;
}
}
DemoTest
package com.itheima;
import org.junit.Assert;
import org.junit.Test;
public class DemoTest {
@Test
public void testSay(){
Demo d=new Demo();
String ret=d.say("itheima");
Assert.assertEquals("hello itheima",ret);
}
}
运行结果
为了更方便的运行compile或者test之类的指令,可以进行如下配置
使用 原型创建maven的web项目
手动把目录补全
在webapp中创建index.jsp 配置本地的tomcat,也可以不配置。选择用插件。用插件配置tomcat的教程继续往下翻 我已经配完了再截图,所以我会有个web01
启动tomcat
如果不配置本地的tomcat,也可以用tomcat有关插件启动maven 的web项目 进入网址
https://mvnrepository.com/https://mvnrepository.com/
搜素 tomcat maven 点击小红框的连接 点击小红框的连接
编辑pom.xml文件
自己写build,把刚才复制的内容,放到plugin里面,修改成如下所示,
!-- 构建-->刷新一下,让idea去下载插件,2minutesorg.apache.tomcat.maven tomcat7-maven-plugin2.2
下载完成后多了个插件 tomcat7
点击tomcat7插件,找到run
再Run控制台中点击网页
运行结果



