使用intellij创建新的maven管理的git控制项目 [英] creating new maven managed git controled project using intellij

查看:6177
本文介绍了使用intellij创建新的maven管理的git控制项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个外部托管的空存储库。我现在想在本地创建一个由源代码控制的intellij / maven托管java项目。



我试过了:

  1>从源代码管理中检出
2>是否要为已检出的源创建IDEA项目? - YES
3>从外部模型导入
4>配置东西
5>选择要导入的maven项目

现在我被卡住了,因为列表是空的。



我也试过了

  1>手动设置maven项目
2>在根目录下初始化git仓库
3>添加原点
4>将项目导入intellij
5>按照intellij的建议配置根目录,用于git
6>提交更改
7>选择push(cvs - > git - > push) - > 没有更改推送

我不明白,原点仍然是一个空的存储库。 / p>

因此,如何告诉intellij在受版本控制的文件夹中创建/使用Maven项目?

解决方案

关键是IDEA如何在检出代码后提示您。有两条类似的消息:


  1. 您是否想为已签出的源创建IDEA项目?

  2. 您已签出IntelliJ IDEA项目文件:{path} /pom.xml您要打开吗?

如果显示的是第一个(它看起来是给你的),IDEA将从源创建一个项目, 不是 来自maven POM。如果是第二个,它将从pom创建它,并且您的IDEA项目将链接到maven POM。即便如此,我个人也喜欢在自动创建对话框中选择否。原因是当选择是时,它立即打开项目。通过一些配置对话框进行下面的操作,并为我提供了更多的灵活性。



一般而言,以下序列适用于以上:


  1. 从源代码管理中退出
  2. 选择
    文件>导入项目

    • 不要与混淆新建新建项目对话框。在文件选择器对话框中,选择根目录 pom.xml







    • $ 通过对话框配置您的maven项目 b

      如果您的初始结账没有POM,您需要执行以下操作来创建Maven链接的IDEA项目:

    • 从源代码管理中检出

    • 选择转到是否要创建项目对话框。 b $ b
    • 文件>新建项目

    • New Project 对话框中:


      1. 在项目类型的Java部分选择Maven / li>
      2. 设置项目名称(Project Name)

      3. 将项目位置值设置为签出项目的根目录。 b $ b
      4. 单击下一步

      5. 为您的新项目设置您的maven坐标
      6. 如果您不想创建标准,请选择原型Java JAR项目
      7. 单击完成


      8. 或者,转至项目>设置> [项目设置]> Maven并调整任何配置

      9. 通过上下文菜单或VCS菜单将pom文件添加到VCS
      10. 编辑您的POM并开始编码


      I got an empty repository hosted externally. I now want to locally create a intellij/maven managed java project which is source controled by that origin.

      I tried:

      1>check out from source control
      2>"would you like to create an IDEA proect for the sources you have checked out?" - YES
      3>import from external model
      4>configure stuff
      5>select maven projects to import
      

      and now I am stuck as the list is empty.

      I also tried

      1> setting up the maven project manually
      2> initializing the git repository in root directory
      3> adding origin
      4> importing project into intellij
      5> configuring the root directory, as suggested by intellij, for git
      6> committing changes
      7> selecting push (cvs -> git -> push) -> "no changes to push"
      

      I do not understand that as the origin is still an empty repository.

      Therefore how do I tell intellij to create/use a maven project in the folder which is version controlled?

      解决方案

      The key is how IDEA prompts you after checking out code. There are two similar messages:

      1. "Would you like to create an IDEA project for the sources you have checked out? or
      2. "You have checked out an IntelliJ IDEA project file: {path}/pom.xml Would you like to open it?

      If the first one is shown (which it appears it was for you), then IDEA will create a project from the sources and not from the maven POM. In the event of the second one, it will create it from the pom and your IDEA project will be linked to the maven POM. Even so, I personally like to select No to the auto create dialog. The reason is that when selecting yes, it opens the project immediately. Doing the below runs through a couple of configuration dialogs and gives me a bit more flexibility in how I set things up.

      In general, the following sequence works for either of the above:

      1. Check out from source control
      2. Select No to the "Do you want to create a project" dialog.
      3. File > Import Project
        • not to be confused with New Project
      4. In the file chooser dialog, select the root pom.xml POM in the check out location from step #1
      5. Configure your maven project via the dialogs

      If your initial checkout does not have a POM, you need to do the following to create a maven linked IDEA project:

      1. Check out from source control
      2. Select No to the "Do you want to create a project" dialog.
      3. File > New Project
      4. In the New Project dialog:

        1. Select "Maven" in the "Java" section of the project types
        2. Set the "Project Name"
        3. Set the "Project Location" value to the root directory of the project you checked out.
        4. Click Next
        5. Set your maven coordinates for your new project
        6. Select an archetype if you do not want to create a standard Java JAR project
        7. Click Finish

      5. Optionally, go to Project > Settings > [Project Settings] > Maven and tweak any configurations
      6. Add the pom file to VCS via the context menu or the VCS menu
      7. Edit your POM and start coding

      这篇关于使用intellij创建新的maven管理的git控制项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆