码迷,mamicode.com
首页 > 其他好文 > 详细

Maven入门_四、Maven项目核心POM

时间:2018-01-16 18:11:12      阅读:111      评论:0      收藏:0      [点我收藏+]

标签:jar   res   项目   execution   coding   mode   build   orm   com   

四、Maven项目核心POM .xml

pom定义了项目的基本信息,描述了项目的构建、依赖

1、Maven项目的基本坐标:

<!-- 项目包名: 公司地址名称反写+项目名称-->
  <groupId>com.xusan</groupId>
<!--项目模块名称:一般为 项目名-模块名 -->
  <artifactId>hello-word</artifactId>
<!-- 指定当前pom 的版本-->
  <version>1.0-SNAPSHOT</version>

2.POM插件配置

(1).查看官方配置文档

官网ManifestResourceTransformer配置

(2).配置pom.xml

<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.xusan</groupId>
  <artifactId>hello-word</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>
  <name>hello-word</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.7</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  
  <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.1.0</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <transformers>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                <manifestEntries>
                                <Main-Class>com.xusan.helloword.HelloWord</Main-Class>                                      
                                </manifestEntries>
                                </transformer>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>    
  
</project>

只要修改包名即可

<manifestEntries>
    <!--改成包名-->
    <Main-Class>com.xusan.helloword.HelloWord</Main-Class>
</manifestEntries>

Maven入门_四、Maven项目核心POM

标签:jar   res   项目   execution   coding   mode   build   orm   com   

原文地址:https://www.cnblogs.com/xuwei1/p/8296365.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!