maven webapp的标准pom.xml配置

转载自https://stackoverflow.com/questions/33184885/artifactdescriptorexception-failed-to-read-artifact-descriptor-for-javax-servle

<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.0modelVersion>
  <groupId>com.jdscgroupId>
  <artifactId>jdartifactId>
  <packaging>warpackaging>
  <version>0.0.1-SNAPSHOTversion>
  <name>jd Maven Webappname>
  <url>http://maven.apache.orgurl>

      <properties>
        <as.default.java.version>1.7as.default.java.version>
        <as.default.junit.version>4.8.2as.default.junit.version>
        <as.default.slf4j.version>1.6.6as.default.slf4j.version>
        <as.default.log4j.version>1.2.16as.default.log4j.version>
        <as.default.javax.servlet.version>2.5as.default.javax.servlet.version>
        <as.default.javax.servlet.jsp.version>2.1as.default.javax.servlet.jsp.version>
        <as.default.springframework.version>4.0.3.RELEASEas.default.springframework.version>
        <as.default.hibernate.version>3.5.0-Finalas.default.hibernate.version>
        <as.default.camel.version>2.9.4as.default.camel.version>
        <as.default.activemq.version>5.6.0as.default.activemq.version>
        <project.build.maven.compiler.plugin.version>2.3.2project.build.maven.compiler.plugin.version>
        <project.build.sourceEncoding>UTF-8project.build.sourceEncoding>
    properties>

  <dependencies>
            <dependency>
                <groupId>org.slf4jgroupId>
                <artifactId>slf4j-apiartifactId>
                <version>${as.default.slf4j.version}version>
                <scope>compilescope>
            dependency>
            <dependency>
                <groupId>org.slf4jgroupId>
                <artifactId>slf4j-log4j12artifactId>
                <version>${as.default.slf4j.version}version>
                <scope>compilescope>
            dependency>
            <dependency>
                <groupId>log4jgroupId>
                <artifactId>log4jartifactId>
                <version>${as.default.log4j.version}version>
                <scope>compilescope>
            dependency>
            <dependency>
                <groupId>junitgroupId>
                <artifactId>junitartifactId>
                <version>${as.default.junit.version}version>
                <scope>testscope>
            dependency>
            <dependency>
                <groupId>javax.servletgroupId>
                <artifactId>servlet-apiartifactId>
                <version>${as.default.javax.servlet.version}version>
                <scope>providedscope>
            dependency>
            <dependency>
                <groupId>javax.servlet.jspgroupId>
                <artifactId>jsp-apiartifactId>
                <version>${as.default.javax.servlet.jsp.version}version>
                <scope>providedscope>
            dependency>
  dependencies>

  <build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.pluginsgroupId>
            <artifactId>maven-compiler-pluginartifactId>
            <configuration>
                <source>1.5source>
                <target>1.5target>
            configuration>
        plugin>
    plugins>  
    <finalName>jdfinalName>
  build>
project>

转载自http://blog.csdn.net/mn960mn/article/details/44858383
包含jsp、servlet、jstl、compiler、tomcat7、jetty的配置

<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.0modelVersion>

    <groupId>com.lalagroupId>
    <artifactId>web-demoartifactId>
    <packaging>warpackaging>
    <version>1.0.0version>

    <name>web-demoname>
    <url>http://maven.apache.orgurl>

    <dependencies>
        <dependency>
            <groupId>junitgroupId>
            <artifactId>junitartifactId>
            <version>4.12version>
            <scope>testscope>
        dependency>
        <dependency>
            <groupId>javax.servletgroupId>
            <artifactId>javax.servlet-apiartifactId>
            <version>3.1.0version>
            <scope>providedscope>
        dependency>
        <dependency>
            <groupId>javax.servlet.jspgroupId>
            <artifactId>jsp-apiartifactId>
            <version>2.2version>
            <scope>providedscope>
        dependency>
        <dependency>
            <groupId>jstlgroupId>
            <artifactId>jstlartifactId>
            <version>1.2version>
        dependency>
        <dependency>
            <groupId>taglibsgroupId>
            <artifactId>standardartifactId>
            <version>1.1.2version>
        dependency>
    dependencies>

    <build>
        <finalName>web-demofinalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.pluginsgroupId>
                <artifactId>maven-compiler-pluginartifactId>
                <version>3.3version>
                <configuration>
                    <source>1.8source>
                    <target>1.8target>
                    <verbose>trueverbose>
                configuration>
            plugin>
            <plugin>
                <groupId>org.eclipse.jettygroupId>
                <artifactId>jetty-maven-pluginartifactId>
                <version>9.4.2.v20170220version>
                <configuration>
                    <stopKey>foostopKey>
                    <stopPort>9999stopPort>
                    <httpConnector>
                        <port>9090port>
                    httpConnector>
                    <webApp>
                        <contextPath>/contextPath>
                    webApp>
                configuration>
            plugin>
            <plugin>
                <groupId>org.apache.tomcat.mavengroupId>
                <artifactId>tomcat7-maven-pluginartifactId>
                <version>2.2version>
                <configuration>
                    <path>/path>
                    <port>9090port>
                    <uriEncoding>UTF-8uriEncoding>
                configuration>
            plugin>
        plugins>
    build>

project>

最后,启动web服务的方式为:
mvn jetty:run

mvn tomcat7:run

你可能感兴趣的:(maven,web,app,java,maven)