- 在idea中新建一个普通maven项目
- 在file--->new--->Project
- 选择maven项目,直接next(非javaee项目)
- 填写项目信息
- 位置和名称自行定义,然后finish;
- 配置pom.xml文件
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>hello-world</artifactId>
<version>1.0-SNAPSHOT</version>
<name>helloworld-01</name>
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<!--<dependency>-->
<!--<groupId>org.apache.kafka</groupId>-->
<!--<artifactId>kafka-clients</artifactId>-->
<!--<version>0.10.0.1-TBDS-4.0.3.3</version>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.apache.kafka</groupId>-->
<!--<artifactId>kafka_2.11</artifactId>-->
<!--<version>0.10.0.1-TBDS-4.0.3.3</version>-->
<!--</dependency>-->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>test.App</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<!--<profile>-->
<!--<id>tbds-profile</id>-->
<!--<repositories>-->
<!--<repository>-->
<!--<id>tbds_public</id>-->
<!--<name>tbds_public_repository</name>-->
<!--<url>https://tbdsrepo.cloud.tencent.com/repository/tbds/</url>-->
<!--<layout>default</layout>-->
<!--</repository>-->
<!--</repositories>-->
<!--<activation>-->
<!--<activeByDefault>true</activeByDefault>-->
<!--</activation>-->
<!--</profile>-->
</profiles>
</project>
- 随便创建一个类,Helloworld
- 根据下图,1-7步,打包,在target目录下面生成了jar包;:
- 在有java的环境(Linux)上执行:java -cp hello-world-1.0-SNAPSHOT.jar com.test.info.Helloworld