---
title: "Maven2编译时“是 Sun 的专用 API，可能会在未来版本中删除”错误解决 "
author: "slikel"
date: "2012-08-28T16:42:19Z"
tags: []
categories: ["研发管理"]
slug: "maven2-sun-api"
draft: false
lastmod: "2012-08-28T16:42:19Z"
id: 1665460
url: "https://slikel.iteye.com/blog/1665460"
---

项目中用到了maven来管理，因为有些功能用到了sun的专用API，在maven编译过程中会报“ 是 Sun 的专用 API，可能会在未来版本中删除 ”这样的错误导致最终编译失败，google了一番可以使用最新版本的编译插件解决这个问题，在项目的pom文件中配置如下：

1、其中maven-compiler-plugin用2.3.1版，之前用的是2.0.2的；

2、必须指定plexus-compiler-javac这个依赖，并且最新版本1.8.1才解决了这个问题，1.8.1以前的是有问题的；

 

**配置如下：**

```
<plugin>

  <artifactId>maven-compiler-plugin</artifactId>

  <version>2.3.1</version>

  <configuration>

    <source>1.6</source>

    <target>1.6</target>

    <encoding>UTF-8</encoding>

  </configuration>

  <dependencies>

    <dependency>

      <groupId>org.codehaus.plexus</groupId>

      <artifactId>plexus-compiler-javac</artifactId>

      <version>1.8.1</version>

    </dependency>

  </dependencies>

</plugin>
```

 

 

(源自：[http://ruijunsuo.blog.163.com/blog/static/4005963220126910225769/](http://ruijunsuo.blog.163.com/blog/static/4005963220126910225769/))