简体   繁体   中英

Intellij IDEA: How to set up Imported Maven Project Correctly?

I downloaded a maven project ( https://github.com/jOOQ/jOOQ ) into Intellij IDEA, as I want to debug the spring-boot testcase org.jooq.example.spring.QueryTest .

I did as described in the example README.md :

$ pwd 
/path/to/checkout/dir
$ ls
jOOQ jOOQ-meta jOOQ-codegen ...
$ mvn clean install
...
$ cd jOOQ-examples/jOOQ-spring-boot-example
...
$ mvn clean install

I set the java source and test directories manually in the IntelliJ project (right mouse click, mark directory as... ) for the java example directory and the java test directory for jooq-spring-boot .

Now I still have a lot of errors, as the further setup of imports etc. seems to be missing. See screenshot. 在此输入图像描述 What do I have to do to remove these errors?

Is there any possibility to automate these steps like setting the test and source directory manually?

I managed to import this same project from github and set up the IntelliJ project correctly within 2 minutes, and here's how:

If you didn't do it already, check out the project from github. If you have an intellij project from before - start over, and check it out again.

VCS -> Check out from Version Control -> GitHub -> https://github.com/jOOQ/jOOQ

Now, after it checks out the project, this is important, when the next dialog window comes, hit CANCEL . You do not want to configure all the modules and source locations manually in the dialog box that follows "Check out from Version Control".

Instead, go to File -> Open... and choose the folder where you just checked out jOOQ from version control.

This will "force" IntelliJ to automatically create a project based on the structure of the pom.xml. It works - I tried it just now, with IntelliJ IDEA 2017.2.2 (upgrade if your version is too old).

Good luck.

为jOOQ创建的全新IntelliJ项目

Edit:

Indeed I saw the same errors when i looked at QueryTest class in jOOQ-spring-example .

It's really simple - you just need to build the module. The generated sources will provide the needed classes (they will no longer be red).

You will notice that the jOOQ-examples folder does not have a pom.xml, so you will need to set up the pom.xml in jOOQ-spring-example manually - right click on the pom.xml and select + Add as Maven Project .

You might need to click Reimport All Maven Projects so that the source and test roots get marked blue and green in the jOOQ-spring-example structure in the project pain.

Then, in the maven window, find jOOQ Spring Example and build it with maven (Lifecycle -> install). Once it builds, the generated sources will be available under jOOQ-spring-example/target/generated-sources - the jooq-h2 folder should be marked blue as a generated source root.

Go back to QueryTest and you can see the classes in the imports are no longer red.

You should be good to go now :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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