IntelliJ IDEA Unable to import maven project

台俊峰 发布于 2015/04/10 17:55
阅读 20K+
收藏 1

打开idea,提示Unable to import maven project,maven相关的功能不能使用。

查看idea的日志显示错误信息如下:

2015-04-10 17:48:12,552 [  42515]  ERROR -      #org.jetbrains.idea.maven - org/apache/maven/settings/building/SettingsBuilder : Unsupported major.minor version 51.0 
java.lang.UnsupportedClassVersionError: org/apache/maven/settings/building/SettingsBuilder : Unsupported major.minor version 51.0
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClassCond(ClassLoader.java:637)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
	at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
	at org.jetbrains.idea.maven.server.Maven32ServerImpl.applyProfiles(Maven32ServerImpl.java:81)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:303)
	at sun.rmi.transport.Transport$1.run(Transport.java:159)
	at java.security.AccessController.doPrivileged(Native Method)
	at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
	at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
	at java.lang.Thread.run(Thread.java:695)
2015-04-10 17:48:12,562 [  42525]  ERROR - til.concurrency.QueueProcessor - org/apache/maven/settings/building/SettingsBuilder : Unsupported major.minor version 51.0 
java.lang.UnsupportedClassVersionError: org/apache/maven/settings/building/SettingsBuilder : Unsupported major.minor version 51.0
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClassCond(ClassLoader.java:637)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
	at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
	at org.jetbrains.idea.maven.server.Maven32ServerImpl.createIndexer(Maven32ServerImpl.java:49)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:303)
	at sun.rmi.transport.Transport$1.run(Transport.java:159)
	at java.security.AccessController.doPrivileged(Native Method)
	at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
	at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
	at java.lang.Thread.run(Thread.java:695)
2015-04-10 17:48:12,563 [  42526]  ERROR - til.concurrency.QueueProcessor - IntelliJ IDEA 14.1.1  Build #IU-141.178.9 
2015-04-10 17:48:12,563 [  42526]  ERROR - til.concurrency.QueueProcessor - JDK: 1.6.0_65 
2015-04-10 17:48:12,563 [  42526]  ERROR - til.concurrency.QueueProcessor - VM: Java HotSpot(TM) 64-Bit Server VM 
2015-04-10 17:48:12,563 [  42526]  ERROR - til.concurrency.QueueProcessor - Vendor: Apple Inc. 
2015-04-10 17:48:12,563 [  42526]  ERROR - til.concurrency.QueueProcessor - OS: Mac OS X 
2015-04-10 17:48:12,563 [  42526]  ERROR - til.concurrency.QueueProcessor - Last Action:  
2015-04-10 17:48:12,563 [  42526]  ERROR -      #org.jetbrains.idea.maven - IntelliJ IDEA 14.1.1  Build #IU-141.178.9 
2015-04-10 17:48:12,563 [  42526]  ERROR -      #org.jetbrains.idea.maven - JDK: 1.6.0_65 
2015-04-10 17:48:12,563 [  42526]  ERROR -      #org.jetbrains.idea.maven - VM: Java HotSpot(TM) 64-Bit Server VM 
2015-04-10 17:48:12,563 [  42526]  ERROR -      #org.jetbrains.idea.maven - Vendor: Apple Inc. 
2015-04-10 17:48:12,564 [  42527]  ERROR -      #org.jetbrains.idea.maven - OS: Mac OS X 
2015-04-10 17:48:12,564 [  42527]  ERROR -      #org.jetbrains.idea.maven - Last Action:  
2015-04-10 17:48:13,743 [  43706]   INFO - indexing.UnindexedFilesUpdater - Indexable files iterated in 6362 ms 
2015-04-10 17:48:14,564 [  44527]   INFO - CompilerWorkspaceConfiguration - Available processors: 4 
2015-04-10 17:48:15,702 [  45665]   INFO - tor.impl.FileEditorManagerImpl - Project opening took 14727 ms 
2015-04-10 17:48:17,580 [  47543]  ERROR - jediterm.terminal.TerminalMode - Mode EightBitInput is not implemented, setting to true 
2015-04-10 17:48:57,452 [  87415]  ERROR -      #org.jetbrains.idea.maven - org/apache/maven/settings/building/SettingsBuilder : Unsupported major.minor version 51.0 
java.lang.UnsupportedClassVersionError: org/apache/maven/settings/building/SettingsBuilder : Unsupported major.minor version 51.0
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClassCond(ClassLoader.java:637)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
	at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
	at org.jetbrains.idea.maven.server.Maven32ServerImpl.applyProfiles(Maven32ServerImpl.java:81)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:303)
	at sun.rmi.transport.Transport$1.run(Transport.java:159)
	at java.security.AccessController.doPrivileged(Native Method)
	at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
	at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
	at java.lang.Thread.run(Thread.java:695)
2015-04-10 17:48:57,453 [  87416]  ERROR -      #org.jetbrains.idea.maven - IntelliJ IDEA 14.1.1  Build #IU-141.178.9 
2015-04-10 17:48:57,453 [  87416]  ERROR -      #org.jetbrains.idea.maven - JDK: 1.6.0_65 
2015-04-10 17:48:57,453 [  87416]  ERROR -      #org.jetbrains.idea.maven - VM: Java HotSpot(TM) 64-Bit Server VM 
2015-04-10 17:48:57,453 [  87416]  ERROR -      #org.jetbrains.idea.maven - Vendor: Apple Inc. 
2015-04-10 17:48:57,453 [  87416]  ERROR -      #org.jetbrains.idea.maven - OS: Mac OS X 
2015-04-10 17:48:57,453 [  87416]  ERROR -      #org.jetbrains.idea.maven - Last Action: Maven.Reimport

在命令行里使用mvn命令完全没有问题,idea版本是14.1.1,maven版本是3.3.1

peak@MacBook-Pro ~$echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home
peak@MacBook-Pro ~$echo $M2_HOME
/usr/local/maven/maven3.3.1/
peak@MacBook-Pro ~$java -version
java version "1.7.0_75"
Java(TM) SE Runtime Environment (build 1.7.0_75-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.75-b04, mixed mode)
peak@taijunfengdeMacBook-Pro ~$mvn -version
Apache Maven 3.3.1 (cab6659f9874fa96462afef40fcf6bc033d58c1c; 2015-03-14T04:10:27+08:00)
Maven home: /usr/local/maven/maven3.3.1
Java version: 1.7.0_75, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: "mac os x", version: "10.10.3", arch: "x86_64", family: "mac"





加载中
4
543706787
543706787

你的环境应该是MacOs吧。首先在MAC下IDEA默认使用但是Java1.6启动。所以在第一次启动时他会建议你安装1.6. 虽然你开发使用的1.7但是他自身环境为1.6.这就导致了maven3无法启动的情况。

修复:

/Applications下找到IntelliJ IDEA 13,右键->显示包内容->Contents->Info.plist,利用文本编辑器或是默认的xcode打开该文件,找到下列代码
<key>JVMVersion</key>
<string>1.6*,1.7+</string>
改为
<key>JVMVersion</key>
<string>1.7+</string>

保存。此时idea使用的jdk就是1.7及以上的版本了。

你从新打开就可以使用系统的maven3了

1
台俊峰
台俊峰

在设置里把maven home设置为idea自带的maven插件目录,问题解决了!

0
ginkgo_w
ginkgo_w

你应该是用的14.1. 14.1对maven3.3.1有bug。在14.1.1里面已经修复了。

https://youtrack.jetbrains.com/issue/IDEA-137783

返回顶部
顶部