Joh*_*rge 5 java eclipse jodatime maven
我正在使用 Eclipse Kepler 和 Apache Maven 3.1.1。据我所知,我刚刚安装了两者并正确安装。
我正在尝试从 Maven 存储库安装 Joda Time。我将依赖项添加到 pom.xml,但即使使用 maven 全新安装,我的项目也无法解析 joda 库。
我的存储库位于 USER_FOLDER/.m2/repository/。在我在提示中导航到我的项目文件夹并运行“mvn clean”,然后运行“mvn install”后,joda-time 文件夹及其内容就会出现在那里。
我没有更改 Eclipse 项目中的任何构建路径或其他项目设置。
安装了 Eclipse Maven 集成。
我按照在 Spring 网站上找到的本教程进行操作:http : //spring.io/guides/gs/maven/
我的文件结构如下:
USER
|____ .m2
| |____ repository
| |____ joda-time [and other folders such as org]
| |____ joda-time
| |____ 2.3
| |____ _remote.repositories
| |____ joda-time-2.3.jar
| |____ joda-time-2.3.jar.sha1
| |____ joda-time-2.3.pom
| |____ joda-time-2.3.pom.sha1
|____ workspace
| |____ hello
| | |____ [project files]
| | |____ pom.xml
| | |____ dependency-reduced-pom.xml
| | |____ target
| | |____ [compiled files. Nothing related to Joda, though]
| |____ .metadata [with .plugins folder and others]
Run Code Online (Sandbox Code Playgroud)
这是我的 pom.xml:
<?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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.springframework</groupId>
<artifactId>gs-maven</artifactId>
<packaging>jar</packaging>
<version>0.1.0</version>
<dependencies>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.3</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>main.java.hello.HelloWorld</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Run Code Online (Sandbox Code Playgroud)
这是我的 HelloWorld.java 主文件。在导入行上,我收到错误消息“无法解析导入 org.joda”。
package main.java.hello;
import org.joda.time.LocalTime;
public class HelloWorld {
public static void main(String[] args) {
LocalTime currentTime = new LocalTime();
}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
8244 次 |
最近记录: |