- 列表内容
Mac+idea(2016.3Community版本)环境下面搭建一个maven for web工程
• Web开发时候,经常使用maven 来管理jar包,所以经常首先创建一个maven工程,本人因为刚使用mac系统和idea开发工具,因各种原因千奇百怪导致有的时候创建的maven工程失败出错等各种问题,特制作此文档,方便今后的使用,以免因此浪费过多的时间,废话少说,开始创建:
• 首先new一个project,勾选Create from archetype 同时选择org.jetbrains.idea.maven.model.MavenArchetype ,Next:
• 这个我就不详细叙述了,填完Next:
• 为了方便快速构建,按 + 添加archetypeCatalog = internal Next
• Event log 会有提醒:
右下角会出现Import字样,点击。
上面的我一般是直接Ignore
稍等一小会儿左下侧message会显示build success,此时高兴过早,还有稍稍一些小配置要手动配置(这种免费版本没办法)
• 因为免费版本没有tomcat插件的,所以,自己“造”一个吧
点击右上角向下的箭头 ,再点击edit configuration
• 此时会弹出一个界面:
此时,点击左上角的 + 按钮 再选择maven 再在左侧填写相关配置:
tomcat7
tomcat7:run-war-only
继续
左侧下面的 + 按钮 选择Run maven Goal 点击OK
clean install -Dmaven.test.skip –U
ps:上面这句话非常小心的使用,多一个空格都不行,不然debug的时候会报错的。
再点右下角OK
• 回到主界面我们来编辑pom.xml 文件添加tomcat7的配置:
• <plugins>
• <plugin>
• <groupId>org.apache.tomcat.maven</groupId>
• <artifactId>tomcat7-maven-plugin</artifactId>
• <version>2.1</version>
• <configuration>
• <port>9090</port>
• <path>/</path>
• <uriEncoding>UTF-8</uriEncoding>
• <server>tomcat7</server>
• </configuration>
• </plugin>
• </plugins>
此时,我们点击右上角的debug按钮
• 此时可以看到端口开启了:
这时候可以去网页打开端口看看了http://localhost:9090 因为pom文件里面我配置的是9090端口所以开启的自然是9090
接着就看到你所期待已久的Hello World!
• 结束!