MAVEN转web项目
来源:互联网 发布:冒泡排序法c程序算法 编辑:程序博客网 时间:2024/05/17 02:26
新建普通maven项目
建立webapp/WEB-INF与web.xml
在src/main下建立webapp/WEB-INF
src/main/webapp/WEB-INF下建立web.xml
- web.xml
<?xml version="1.0" encoding="UTF-8"?><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> <display-name>hello app server</display-name> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list></web-app>
添加依赖
更改为war<packaging>war</packaging><dependency> <groupId>com.sun</groupId> <artifactId>tools</artifactId> <version>1.7</version> <scope>system</scope> <systemPath>${JAVA_HOME}/lib/tools.jar</systemPath> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.8.2</version> <scope>test</scope> </dependency> <!-- servlet --> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.1.0</version> <scope>provided</scope> </dependency> <!--jsp --> <dependency> <groupId>javax.servlet.jsp</groupId> <artifactId>jsp-api</artifactId> <version>2.2</version> <scope>provided</scope> </dependency> <!-- jstl --> <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <version>1.2</version> <scope>runtime</scope> </dependency>
选中项目右键maven-update project configuration这样就变成web项目
(可选)添加jetty插件(tomcat跳过)
<build> <finalName>hello</finalName> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.3</version> <configuration> <source>1.7</source> <target>1.7</target> <encoding>UTF-8</encoding> </configuration> </plugin> <!--jetty --> <plugin> <groupId>org.mortbay.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <!-- <version>8.1.14.v20131031</version> --> <version>8.1.16.v20140903</version> <configuration> <scanIntervalSeconds>600</scanIntervalSeconds> <scanTargetPatterns> <scanTargetPattern> <directory>src/main/webapp</directory> <includes> <include>**/*.xml</include> <include>**/*.properties</include> <include>**/*.tld</include> </includes> </scanTargetPattern> </scanTargetPatterns> <webAppConfig> <contextPath>/hello</contextPath> </webAppConfig> <connectors> <connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector"> <port>9090</port> <maxIdleTime>60000</maxIdleTime> </connector> </connectors> </configuration> </plugin> </plugins> </build>
完成的pom
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.ghg</groupId> <artifactId>hello</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>war</packaging> <name>hello</name> <url>http://maven.apache.org</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <dependency> <groupId>com.sun</groupId> <artifactId>tools</artifactId> <version>1.7</version> <scope>system</scope> <systemPath>${JAVA_HOME}/lib/tools.jar</systemPath> </dependency> <!--test --> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.8.2</version> <scope>test</scope> </dependency> <!-- servlet --> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.1.0</version> <scope>provided</scope> </dependency> <!--jsp --> <dependency> <groupId>javax.servlet.jsp</groupId> <artifactId>jsp-api</artifactId> <version>2.2</version> <scope>provided</scope> </dependency> <!-- jstl --> <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <version>1.2</version> <scope>runtime</scope> </dependency> </dependencies> <build> <finalName>hello</finalName> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.3</version> <configuration> <source>1.7</source> <target>1.7</target> <encoding>UTF-8</encoding> </configuration> </plugin> <!--jetty --> <plugin> <groupId>org.mortbay.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <!-- <version>8.1.14.v20131031</version> --> <version>8.1.16.v20140903</version> <configuration> <scanIntervalSeconds>600</scanIntervalSeconds> <scanTargetPatterns> <scanTargetPattern> <directory>src/main/webapp</directory> <includes> <include>**/*.xml</include> <include>**/*.properties</include> <include>**/*.tld</include> </includes> </scanTargetPattern> </scanTargetPatterns> <webAppConfig> <contextPath>/hello</contextPath> </webAppConfig> <connectors> <connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector"> <port>9090</port> <maxIdleTime>60000</maxIdleTime> </connector> </connectors> </configuration> </plugin> </plugins> </build></project>
选中项目右键maven-update project configuration这样就变成web项目
0 0
- MAVEN转web项目
- Maven项目转web项目
- 将普通web项目转maven项目
- MyEclipse2015 Web项目转Maven项目
- 普通web项目转maven项目
- Java项目转maven项目,java项目转web项目
- [maven]构建maven web项目
- java web 项目 转 maven java web 项目(旧项目 转maven)遇到的问题
- 转eclipse maven web 项目建立过程
- eclipse 中创建maven web项目 <转>
- Maven创建web项目具体步骤【转】
- (转)eclipse 中创建maven web项目
- Java Web项目转Maven工程
- maven创建web项目
- Maven构建Web项目
- maven创建web项目
- maven创建web项目
- Maven Web 项目
- 【SSH进阶之路】【十】hibernate5 注解映射【2】 一对多单向关联
- JAVA集合汇总
- .net页面跳转
- 关于charles的使用
- Spring Boot Actuator监控端点小结
- MAVEN转web项目
- Linux常用命令-挂载命令
- ubuntu 16.04安装opencv 2.4.9
- 【Unity】常用代码(一)
- IOS开发 UIScrollView 的属性和基本应用
- 基于Spring、Hibernate的通用DAO层与Service层的实现
- Uinty设置窗口大小和无边框模式
- 【Unity3D游戏开发】之常用代码 (二)
- 临时笔记&问题记录