引入下载的jar包。
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.8</source> <target>1.8</target> <encoding>UTF-8</encoding> <compilerArguments> <extdirs>${project.basedir}/libs</extdirs> </compilerArguments> </configuration> </plugin> <!-- 指定启动类,将依赖打成外部jar包 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <configuration> <archive> <!-- 生成的jar中,不要包含pom.xml和pom.properties这两个文件 --> <addMavenDescriptor>false</addMavenDescriptor> <manifest> <!-- 是否要把第三方jar加入到类构建路径 --> <addClasspath>true</addClasspath> <!-- 外部依赖jar包的最终位置 --> <classpathPrefix>lib/</classpathPrefix> <!-- 项目启动类 --> <mainClass>Main</mainClass> </manifest> <manifestEntries> <Class-Path>lib/aspose-words-21.1.0.jar</Class-Path> </manifestEntries> </archive> </configuration> </plugin> <!--拷贝依赖到jar外面的lib目录--> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <executions> <execution> <id>copy-lib</id> <phase>package</phase> <goals> <goal>copy-dependencies</goal> </goals> <configuration> <outputDirectory>target/lib</outputDirectory> <excludeTransitive>false</excludeTransitive> <stripVersion>false</stripVersion> <includeScope>compile</includeScope> </configuration> </execution> </executions> </plugin> </plugins> </build>
如果本地运行可以,cmd不行。使用如下命令
java -Dfile.encoding=utf-8 file-to-html-1.0-SNAPSHOT.jar