idea新建maven web项目

1.如果已有项目,打开idea,按提示下一步

idea新建maven web项目

使用archetype生成项目骨架,并选择org.apache.maven.archetypes:maven-archetype-webapp,用于生成web项目骨架

idea新建maven web项目

输入GroupId和ArtifactId ,具体意思请看我的另一篇博文https://blog.****.net/jinhaijing/article/details/80609833

idea新建maven web项目

选择安装maven信息

idea新建maven web项目

如图,Project name为项目名称;Project location填写项目放置的位置,根目录最好填写IdeaProjects。保存选择新打开窗口

idea新建maven web项目

完成后,生成项目如下:如果缺少相关目录,手动新建即可。

idea新建maven web项目

其中src/main/java标识为:Sources Root

      src/main/resources标识为:Resources Root

      src/test/java标识为:Test Sources Root

方法如下:

idea新建maven web项目

双击蓝色Java目录,出现弹出框:

idea新建maven web项目

有子web目录即配置正确,如果没有,File-->setting-->Build,Execution,Deployment-->Build Tools-->Maven-->Importing下Import Maven projects automatically前面打钩

idea新建maven web项目

保存重启即可。此作用是生成artifact,在tomcat添加项目时,才能选择artifact

idea新建maven web项目