Maven的使用

Maven介绍

Maven依赖Java运行环境,因此使用Maven之前需要配置Java的运行环境

不同IDE中的Maven

Eclipse

Windows--Preference
    C:\My_Files\Maven\apache-maven-3.3.9\conf\settings.xml
    C:\My_Files\Maven\Repository\3.3.9
    C:\My_Files\Maven\apache-maven-3.3.9\bin
Eclipse使用的Maven库
    C:\My_Files\Maven\Repository\3.3.9
    C:\Users\yt\.m2\repository\org\apache\hive

Idea 中使用的Maven版本和使用的Maven库

Setting---Build,Execution,Deployment------Build Tools---Maven
intellij idea已经集成maven插件了,省去了安装的麻烦
    Maven 版本  bunbled Maven 3.0.5  捆绑
    Maven库: C:\Users\yt\.m2\

Maven的pom.xml

依赖设置
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <source>1.8</source>
                        <target>1.8</target>
                    </configuration>
                </plugin>
                <plugin>
                    <artifactId> maven-assembly-plugin </artifactId>
                    <version>2.6</version>
                    <configuration>
                        <descriptorRefs>
                            <descriptorRef>jar-with-dependencies</descriptorRef>
                        </descriptorRefs>
                        <archive>
                            <manifest>
                                <mainClass>TopologyMain.java</mainClass>
                            </manifest>
                        </archive>
                    </configuration>
                    <executions>
                        <execution>
                            <id>make-assembly</id>
                            <phase>package</phase>
                            <goals>
                                <goal>single</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
            <resources>
                <resource>
                    <directory>src/main/java</directory>
                    <includes>
                        <include>**/*.properties</include>
                    </includes>
                </resource>
            </resources>
        </build>

Maven命令

         mvn -version
         mvn clean package

blogroll

social