Intellij idea下的maven web工程
来源:互联网 发布:网络维护这个工作好吗 编辑:程序博客网 时间:2024/05/23 02:20
新建
新建maven项目,create from archetype,选择maven-archetype-webapp
Next,填写GroupId,ArtifactId和Version
Next,这里在Properties中添加一个参数archetypeCatalog=internal
,不加这个参数,在maven生成骨架的时候将会非常慢,有时候会直接卡住。
来自网上的解释:
archetypeCatalog表示插件使用的archetype元数据,不加这个参数时默认为remote,local,即中央仓库archetype元数据,由于中央仓库的archetype太多了,所以导致很慢,指定internal来表示仅使用内部元数据。
Next,填写项目名称和module名称。
点击Finish。
项目的目录结构如下:
配置Jetty(在pom.xml中)
<plugin> <groupId>org.mortbay.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <version>8.1.16.v20140903</version> <configuration> <systemProperties> <force>true</force> <systemProperty> <name>environment</name> <value></value> </systemProperty> <systemProperty> <name>app.key</name> <value>d</value> </systemProperty> <systemProperty> <name>app.port</name> <value>8080</value> </systemProperty> </systemProperties> <stopKey>xx</stopKey> <stopPort>5666</stopPort> <scanIntervalSeconds>0</scanIntervalSeconds> <reload>manual</reload> <!-- webAppConfig is is an alias for webApp--> <webApp> <contextPath>/</contextPath> <parentLoaderPriority>true</parentLoaderPriority> <allowDuplicateFragmentNames>true</allowDuplicateFragmentNames> </webApp> <connectors> <connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector"> <port>8080</port> <maxIdleTime>60000</maxIdleTime> </connector> </connectors> </configuration> </plugin>
配置web时需要注意的几点
配置web.xml(servlet容器)
<servlet> <servlet-name>DispatcherServlet</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet>
<servlet-mapping> <servlet-name>DispatcherServlet</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping>
配置applicationContext.xml
<context:component-scan base-package="com.d.controller"></context:component-scan> <mvc:annotation-driven /> <bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/> <property name="prefix" value="/WEB-INF/pages/"/> <property name="suffix" value=".jsp"/> </bean>
在配置过程中遇到的问题
在Intellij Idea中进行web工程配置时,由于开始并没有建立maven工程,后来通过Intellij idea 的Add Framework Support来构建的maven,然后通过maven添加jetty插件,这样添加的插件,是不会将工程自动部署到jetty容器上的(如果是在intellij中创建maven项目 intellij会给你配置好所有的配置 )。
通过后期构建maven,对应的Project Settings的Artifacts是空的,没有任何配置的,是需要自己手动去添加的。
通过构建maven项目获取的配置是这样的(图参考http://www.cnblogs.com/jifeng/p/4658765.html)
总的来说其实就是没有将工程自动部署到jetty容器上
如果没有部署的话,会出现404的错误。
0 0
- Intellij idea下的maven web工程
- IntelliJ IDEA快速创建Maven工程的WEB项目
- IntelliJ IDEA导入Maven构建的Web工程
- intellij idea 搭建maven的javaweb工程.
- IntelliJ IDEA 创建并部署单纯的web工程(不用Maven和Gradle管理)
- Intellij Idea 创建 Maven 工程
- IntelliJ IDEA 创建Maven 工程
- Windows下使用IntelliJ IDEA创建Maven工程
- IntelliJ IDEA Maven的工程,未结束的字符串文字
- Intellij IDEA-maven工程编译报错的解决办法
- intelliJ IDEA 创建maven android工程的方法
- Intellij idea 解决 maven工程的部分依赖问题
- IDEA下maven工程的classpath
- Intellij idea使用Maven管理Scala工程
- intellij idea maven 工程junit4单元测试
- Intellij-idea 如何编译maven工程
- Intellij-idea 如何编译maven工程
- 《intellij idea学习经历》-01- 使用IntelliJ IDEA 构建Maven的web项目
- keil MDK5搭建STM32开发环境
- Silverlight 自定义加密
- hdoj3183【思维】
- 八大排序算法
- Android Studio编译google PinyinIME
- Intellij idea下的maven web工程
- 我的Android面试之旅
- 命令行配置wifi
- Hdu-5869 Different GCD Subarray Query(区间不同值离线算法)
- 等式变换
- hdu 1496 QQpet exploratory park 水概率dp
- appium的几点总结
- Fiddler 抓包软件的安装和使用
- 浅析Socket