Javaweb-pom文件


pom.xml是maven的核心配置文件

<?xml version="1.0" encoding="UTF-8"?>


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

  
  <groupId>org.examplegroupId>
  <artifactId>servlet01artifactId>
  <version>1.0-SNAPSHOTversion>
  
  <packaging>warpackaging>

  <name>servlet01 Maven Webappname>
  
  <url>http://www.example.comurl>

  
  <properties>
    
    <project.build.sourceEncoding>UTF-8project.build.sourceEncoding>
    
    <maven.compiler.source>1.7maven.compiler.source>
    <maven.compiler.target>1.7maven.compiler.target>
  properties>

  
  <dependencies>
    
    <dependency>
      <groupId>junitgroupId>
      <artifactId>junitartifactId>
      <version>4.11version>
      <scope>testscope>
    dependency>
  dependencies>

  
  <build>
    <finalName>servlet01finalName>
    <pluginManagement>
      <plugins>
        <plugin>
          <artifactId>maven-clean-pluginartifactId>
          <version>3.1.0version>
        plugin>
        
        <plugin>
          <artifactId>maven-resources-pluginartifactId>
          <version>3.0.2version>
        plugin>
        <plugin>
          <artifactId>maven-compiler-pluginartifactId>
          <version>3.8.0version>
        plugin>
        <plugin>
          <artifactId>maven-surefire-pluginartifactId>
          <version>2.22.1version>
        plugin>
        <plugin>
          <artifactId>maven-war-pluginartifactId>
          <version>3.2.2version>
        plugin>
        <plugin>
          <artifactId>maven-install-pluginartifactId>
          <version>2.5.2version>
        plugin>
        <plugin>
          <artifactId>maven-deploy-pluginartifactId>
          <version>2.8.2version>
        plugin>
      plugins>
    pluginManagement>
  build>
project>

maven由于他的约定大于配置,我们可能会遇到我们写的配置文件,无法被导初或者生效的问题,解决方案:

    
    <build>
        <resources>
            <resource>
                <directory>src/main/resourcesdirectory>
                <excludes>
                    <exclude>**/*.propertiesexclude>
                    <exclude>**/*.xmlexclude>
                excludes>
                <filtering>falsefiltering>
            resource>
            <resource>
                <directory>src/main/javadirectory>
                <includes>
                    <include>**/*.propertiesinclude>
                    <include>**/*.xmlinclude>
                includes>
                <filtering>falsefiltering>
            resource>
        resources>
    build>

idea操作:

------------恢复内容结束------------