创建Maven WebApp 新项目 for Eclipse
#新建web项目
File/Other/Maven/Maven Project
选择Maven-archetype-webapp项

Group Id=com.cwgis
Artifact Id=portal
version: 1.0
Package=com.cwgis.portal
点击创建Finish完成创建Webapp项目创建

创建Maven WebApp 新项目 for Eclipse

#环境设置
portal工程目录右键属性Properties
Properties for portal/Project Facets设置
Java Compiler:Compiler compliance level=1.8, Apply应用
(1)先去掉打勾Dynamic Web Module
(2)然后Java版本选择1.8,点击Apply应用
(3)然后Dynamic Web Module版本选择4.0,重新打打勾Dynamic Web Module
配置界面下面新出现有一个设置选项Futher Configuration available,
点击进入 设置 Content Dirctory=src/main/webapp
下面打勾Generate web.xml deployment descrptor,然后点击OK完成设置
点击Apply应用
创建Maven WebApp 新项目 for Eclipse
src/main/webapp/index.jsp

<html>
<body>
<h2>Hello World!</h2>
</body>
</html>

portal工程目录右键属性export/war file
生成war文件并部署到tomcat9\webapps\目录下面
tomcat9\webapps\portal.war
然后重新启动tomcat
portal.war会自动解压到D:\cwgis\apps\tomcat9\webapps\portal目录中
就可以查看运行结果:
http://localhost:8080/portal

Hello World!

eclipse 中index.jsp 页面右键 runas run on Server
配置run Configation tomcat9
创建Maven WebApp 新项目 for Eclipse
下面Servers面板中选中Tomcat v9.0 Server at localhost 右键Start开启服务后,
再运行run on Server
创建Maven WebApp 新项目 for Eclipse
设置web.xml
src/main/webapp/WEB-INF/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/nl/javaee/web-app_3_0.xsd"
    version="3.0" >  
  <display-name>portal</display-name>  
  <welcome-file-list>
  	<welcome-file>index.html</welcome-file>
  	<welcome-file>index.htm</welcome-file>
  	<welcome-file>index.jsp</welcome-file>
  	<welcome-file>default.html</welcome-file>
  	<welcome-file>default.htm</welcome-file>
  	<welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
</web-app>

自定义添加pom.xml内容:然后等待maven自动从网上下载相关依赖项组件

<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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.cwgis</groupId>
  <artifactId>portal</artifactId>
  <packaging>war</packaging>
  <version>1.0</version>
  <name>portal Maven Webapp</name>
  <url>http://maven.apache.org</url>
 <dependencies>
 <dependency>
     <groupId>org.eclipse.jetty.aggregate</groupId>
     <artifactId>jetty-all</artifactId>
     <version>8.1.8.v20121106</version>
</dependency>
<dependency>
     <groupId>org.eclipse.jetty</groupId>
     <artifactId>jetty-webapp</artifactId>
     <version>8.1.8.v20121106</version>
</dependency>
<dependency>
    <groupId>org.eclipse.jetty</groupId>
    <artifactId>jetty-jsp-2.1</artifactId>
    <version>7.2.2.v20101205</version>
</dependency>
<dependency>
    <groupId>org.mortbay.jetty</groupId>
    <artifactId>jsp-2.1-glassfish</artifactId>
    <version>2.1.v20100127</version>
</dependency>
   <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.11</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.spark</groupId>
      <artifactId>spark-core_2.11</artifactId>
      <version>2.3.1</version>
    </dependency>
    <dependency>
      <groupId>mil.nga.giat</groupId>
      <artifactId>geowave-analytic-spark</artifactId>
      <version>0.9.7</version>
    </dependency>
    <dependency>
      <groupId>mil.nga.giat</groupId>
      <artifactId>geowave-datastore-hbase</artifactId>
      <version>0.9.7</version>
    </dependency>
    <dependency>
      <groupId>mil.nga.giat</groupId>
      <artifactId>geowave-adapter-vector</artifactId>
      <version>0.9.7</version>
    </dependency>
    <dependency>
      <groupId>org.apache.hadoop</groupId>
      <artifactId>hadoop-client</artifactId>
      <version>2.7.4</version>
    </dependency>
    <dependency>
             <groupId>mysql</groupId>
             <artifactId>mysql-connector-java</artifactId>
             <version>6.0.6</version>
    </dependency>
  </dependencies>
  <build>
    <finalName>cwgis.portal</finalName>
    <pluginManagement>
      <plugins>
        <plugin>
          <artifactId>maven-clean-plugin</artifactId>
          <version>3.0.0</version>
        </plugin>        
        <plugin>
          <artifactId>maven-resources-plugin</artifactId>
          <version>3.0.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.7.0</version>
        </plugin>
        <plugin>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>2.20.1</version>
        </plugin>
        <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.6</version>
        <configuration>
            <failOnMissingWebXml>false</failOnMissingWebXml>
        </configuration>
     </plugin>
        <plugin>
          <artifactId>maven-install-plugin</artifactId>
          <version>2.5.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-deploy-plugin</artifactId>
          <version>2.8.2</version>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>
</project>

相关文章:

  • 2021-05-29
  • 2021-09-18
猜你喜欢
  • 2021-03-30
相关资源
相似解决方案