简体   繁体   English

如何在我的 Mac 上找到 Joda-Time Jar 文件?

[英]How can i find Joda-Time Jar file on my Mac?

As far as i know, once you use a maven library in pom.xml, a jar file will be downloaded to your computer.据我所知,一旦您在 pom.xml 中使用 maven 库,jar 文件将被下载到您的计算机。 I have used Joda-Time in my pom.xml, but i cannot find the joda-time-2.10.13.jar on my Mac我在我的 pom.xml 中使用了 Joda-Time,但我在我的 Mac 上找不到 joda-time-2.10.13.jar

As far as I know, it only adds the library's code to the exported project but does not directly download it to any path.据我所知,它只是将库的代码添加到导出的项目中,而不是直接将其下载到任何路径。 If you just want the file you can download it here如果你只想要文件,你可以在这里下载

Joda-Time乔达时间

If using Apache Maven as your dependency manager, visit the Joda-Time web site to find the needed entry for yourPOM file.如果使用Apache Maven作为依赖项管理器,请访问Joda-Time web 站点以查找POM文件所需的条目。

Currently:目前:

<dependency>
  <groupId>joda-time</groupId>
  <artifactId>joda-time</artifactId>
  <version>2.10.13</version>
</dependency>

Here is an example POM created by starting a new project with theApache Maven Quickstart archetype.这是通过使用Apache Maven 快速入门原型启动新项目创建的示例 POM。 I modified this to (a) add the Joda-Time dependency, (b) use latest versions for all parts, and (c) specify version of Java via <maven.compiler.release> element.我将其修改为 (a) 添加 Joda-Time 依赖项,(b) 对所有部分使用最新版本,以及 (c) 通过<maven.compiler.release>元素指定 Java 的版本。

<?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>

    <groupId>work.basil.example</groupId>
    <artifactId>JodaTimeExample</artifactId>
    <version>1.0-SNAPSHOT</version>

    <name>JodaTimeExample</name>
    <!-- FIXME change it to the project's website -->
    <url>http://www.example.com</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.release>17</maven.compiler.release>
    </properties>

    <dependencies>

        <!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter -->
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <version>5.8.2</version>
            <scope>test</scope>
        </dependency>

        <!-- https://mvnrepository.com/artifact/joda-time/joda-time -->
        <dependency>
            <groupId>joda-time</groupId>
            <artifactId>joda-time</artifactId>
            <version>2.10.13</version>
        </dependency>

    </dependencies>

    <build>
        <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
            <plugins>
                <!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
                <plugin>
                    <artifactId>maven-clean-plugin</artifactId>
                    <version>3.1.0</version>
                </plugin>
                <!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
                <plugin>
                    <artifactId>maven-resources-plugin</artifactId>
                    <version>3.2.0</version>
                </plugin>
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.8.1</version>
                </plugin>
                <plugin>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>3.0.0-M5</version>
                </plugin>
                <plugin>
                    <artifactId>maven-jar-plugin</artifactId>
                    <version>3.2.0</version>
                </plugin>
                <plugin>
                    <artifactId>maven-install-plugin</artifactId>
                    <version>3.0.0-M1</version>
                </plugin>
                <plugin>
                    <artifactId>maven-deploy-plugin</artifactId>
                    <version>3.0.0-M1</version>
                </plugin>
                <!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
                <plugin>
                    <artifactId>maven-site-plugin</artifactId>
                    <version>3.9.1</version>
                </plugin>
                <plugin>
                    <artifactId>maven-project-info-reports-plugin</artifactId>
                    <version>3.1.2</version>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
</project>

Save your edited POM, make Maven re-parse that POM, and clean-and-build your project.保存您编辑的 POM,让 Maven 重新解析该 POM,然后清理并构建您的项目。 After a while (while downloads happen), go check the folders where your external libraries are kept.一段时间后(下载时),go 检查保存外部库的文件夹。 Verify the folder contains joda-time-2.10.13.jar .验证文件夹是否包含joda-time-2.10.13.jar

In my case, on a MacBook Pro running macOS Big Sur, the JAR could be found at:就我而言,在运行 macOS Big Sur 的 MacBook Pro 上,可以在以下位置找到 JAR:

/Users/basil_dot_work/.m2/repository/joda-time/joda-time/2.10.13/joda-time-2.10.13.jar /Users/basil_dot_work/.m2/repository/joda-time/joda-time/2.10.13/joda-time-2.10.13.jar

At that point, edit the main .java file to use the Joda-Time classes.此时,编辑主.java文件以使用Joda-Time类。

package work.basil.example;

import org.joda.time.DateTime;

/**
 * Hello world!
 */
public class App
{
    public static void main ( String[] args )
    {
        System.out.println( 
            "At the tone the time will be: " + 
            DateTime.now() 
        );
    }
}

When run, see output such as:运行时见 output 如:

At the tone the time will be: 2021-12-10T16:58:38.076-08:00在音调时间将是:2021-12-10T16:58:38.076-08:00

java.time java.time

Be aware that the Joda-Time project is now in maintenance mode .请注意, Joda-Time项目现在处于维护模式

The creator of Joda-Time, Stephen Colebourne, took lessons learned and went on to lead the JSR 310 project. Joda-Time 的创建者 Stephen Colebourne 吸取了教训并继续领导JSR 310项目。 That project resulted in the java.time classes being built into Java 8 and later.该项目导致java.time类被内置到 Java 8 及更高版本中。

If starting a new project, you should use the java.time classes rather than Joda-Time.如果开始一个新项目,您应该使用java.time类而不是 Joda-Time。

If maintaining an app that already uses Joda-Time, you may continue using Joda-Time.如果维护一个已经使用 Joda-Time 的应用程序,您可以继续使用 Joda-Time。 The project is maintained with updates to the tz database , and with any crucial bug fixes.该项目通过对tz数据库的更新以及任何重要的错误修复进行维护。 But since no further feature work is being done, consider planning for a migration to java.time when convenient.但由于没有进一步的功能工作,请考虑在方便的时候计划迁移到java

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM