Maven打包遇到的一些问题(zhuan)

时间:2023-12-04 13:06:44

http://qqbwww.iteye.com/blog/2042307

****************************************

#Maven打包遇到的一些问题

## 1.将依赖打成一个包
参考这篇

## 2.Fatal error compiling: 无效的目 标版本: 1.7 -> [Help 1]

因为是在cmd中执行,然后maven依赖jdk,我的环境变量中将JAVA_HOME写死,指导了jdk1.6版本。而这个项目需要1.7版本,在POM文件的编译插件中

  1. <plugin>
  2. <artifactId>maven-compiler-plugin</artifactId>
  3. <version>3.1</version>
  4. <configuration>
  5. <source>1.7</source>
  6. <target>1.7</target>
  7. </configuration>
  8. </plugin>

将版本设置为1.7就会报上面的错误。重新指定环境变量JAVA_HOME指到支持1.7以上的JDK就可以了

eg

<?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.0</modelVersion>
<parent>
<!-- Your own application should inherit from spring-boot-starter-parent -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-samples</artifactId>
<version>2.0.0.BUILD-SNAPSHOT</version>
</parent>
<artifactId>spring-boot-sample-web-thymeleaf3</artifactId>
<name>Spring Boot Web Thymeleaf 3 Sample</name>
<description>Spring Boot Web Thymeleaf 3 Sample</description>
<url>http://projects.spring.io/spring-boot/</url>
<organization>
<name>Pivotal Software, Inc.</name>
<url>http://www.spring.io</url>
</organization>
<properties>
<main.basedir>${basedir}/../..</main.basedir>
<thymeleaf.version>3.0.2.RELEASE</thymeleaf.version>
<thymeleaf-layout-dialect.version>2.1.1</thymeleaf-layout-dialect.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
</project>