【发布时间】:2016-04-08 13:35:06
【问题描述】:
我是 Spring 和 Maven 开发的新手,我正在制作示例指南:https://spring.io/guides。
实际上我正在尝试用 eclipse 制作一个 jar 文件。
我下面的指南是这个:https://spring.io/guides/gs/device-detection/
信息:
系统: Windows 8.1 (x64) - i5-62000U @ 2.30GHz
我在代理后面 - 它的所有设置和 eclipse 成功处理所有依赖项。
Eclipse: JEE Mars 2(4.5.2 版)
Java:JDK 1.8.0_77
JRE:JRE 1.8.0_77
Maven: 3.3.9
M2E:安装在我的eclipse中(自带JEE版本)。
STS:我没有使用 Spring Tool Suite Eclipse,只使用 Clean JEE Eclipse。
环境变量: JAVA_HOME、M2_HOME 都设置好了,接下来我放上我的路径。
Windows 路径:
C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\OpenVPN\bin;C:\Program Files (x86)\Skype\Phone\;C:\Progra~1\apache-maven-3.3.9\bin;C:\Program Files\Java\jdk1.8.0_77\bin
上下文:
我已经使用 skip arcthetype 选择创建了项目,并用所有依赖项声明它是干净的(按照示例)。
POM:
<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>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.3.RELEASE</version>
</parent>
<groupId>org.springframework</groupId>
<artifactId>gs-device-detection</artifactId>
<version>0.1.0</version>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.mobile</groupId>
<artifactId>spring-mobile-device</artifactId>
</dependency>
</dependencies>
<properties>
<java.version>1.8</java.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-releases</id>
<name>Spring Milestone Repository</name>
<url>https://repo.spring.io/libs-release</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-releases</id>
<name>Spring Milestone Repository</name>
<url>https://repo.spring.io/libs-release</url>
</pluginRepository>
</pluginRepositories>
</project>
.m2 文件夹内的 XML 设置:
<?xml version="1.0" encoding="UTF-8"?>
<settings>
<proxies>
<proxy>
<id>optional</id>
<active>true</active>
<protocol>http</protocol>
<username>MY_USER</username>
<password>MY_PASSWORD</password>
<host>MY_HOST</host>
<port>3128</port>
</proxy>
</proxies>
</settings>
“mvn -version”的输出:
C:\Users\MY_USER>mvn -version
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T17:41:47+01:00)
Maven home: C:\Progra~1\apache-maven-3.3.9
Java version: 1.8.0_77, vendor: Oracle Corporation
Java home: C:\Progra~1\Java\jdk1.8.0_77\jre
Default locale: it_IT, platform encoding: Cp1252
OS name: "windows 8.1", version: "6.3", arch: "amd64", family: "dos"
问题:
到目前为止,我已经能够编译、运行和创建独立的 jar 文件服务,但在命令提示符中使用(每个都完美):
mvn spring-boot:run
mvn clean package
我的问题是当我在 Eclipse 中执行操作时:选择 Project > Run as.. Maven Build
总是得到这个异常(无论我改变了什么或我在系统中放置或编辑或重新安装了什么):
java.lang.Exception: classworlds configuration not specified nor found in the classpath at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
到目前为止我做了什么?
第一
在我从零开始更改和重新安装的所有设置中(甚至是 Java 和 Maven)。
我注意到这是专家会理解的丛中这个“启动器”的源代码,但我放链接是为了所有有同样问题的人:
我看到我在 maven 安装目录中缺少一个 classworlds.conf 文件,但我不知道里面应该有什么或放在哪里。
第二
我还在 GitHub 上看到一些程序员有自己的 classwordls.conf 文件,但我不明白我必须把它放在哪里,或者为什么这个异常只出现在 Eclipse 中而不出现在命令提示符中。
第三
我还注意到有些人已将 M2_HOME 更改为 M3_HOME(适用于我在 StackOverflow 中看到的一些 Mac 用户)。
第四次
我看到其他人说这是对位于 M2_HOME\boot 中的“plexus-classworlds-2.5.2.jar”的依赖。我不明白为什么,Maven “应该” 处理所有依赖项。
提前谢谢你。
【问题讨论】:
-
试试 NetBeans 而不是 Eclipse! :-)
-
我希望我可以,不幸的是我在工作的地方我必须坚持使用 Eclipse。
-
到目前为止,我发现 Eclipse Mars 存在问题。我安装了 Luna 并使用了依赖项。火星上没有结果
标签: java eclipse spring maven spring-mvc