Skip to content

Instantly share code, notes, and snippets.

@ericzhong
Last active November 24, 2017 07:10
Show Gist options
  • Save ericzhong/b609e8210417018a653b018706f84d72 to your computer and use it in GitHub Desktop.
Save ericzhong/b609e8210417018a653b018706f84d72 to your computer and use it in GitHub Desktop.
Eclipse

安装

  • Mac

    官网的安装包需要从仓库下载文件,容易超时。

    下载页面下方有几个链接,可以选择OBEO下载离线安装包。

概念

版本

4.7 Oxygen

4.6 Neon

Maven 插件

安装 Maven 插件

点击 Help -> Install New Software,搜索关键字后选择指定包安装,可能比较慢。

创建 Maven 项目:File -> New -> Other -> Maven -> Maven Project

Maven 自动更新依赖中断后手动启动

在项目上点击右键,然后选择 maven -> update project -> Force Update of Snapshots/Releases

运行 Maven 命令

在项目上点击右键,然后选择 Run As -> Maven build...,在 Goals 中输入命令,比如 compile

下次选择 Maven build 即可在执行历史中直接选择。

把依赖打入 jar 包

pom.xml 增加插件,内容如下:

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-assembly-plugin</artifactId>
        <configuration>
          <archive>
            <manifest>
              <mainClass>org.mycompany.app.learn_mahout.Recommender</mainClass>         <!-- 必须有 -->
            </manifest>
          </archive>
          <descriptorRefs>
            <descriptorRef>jar-with-dependencies</descriptorRef>
          </descriptorRefs>
        </configuration>
      </plugin>
    </plugins>
  </build>

然后执行 mvn clean compile assembly:single -Dmaven.test.skip=true,将在 target 目录下生成 *-jar-with-dependencies.jar

想运行程序就执行:java -jar *-jar-with-dependencies.jar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment