How do I get Eclipse to resolve classes generated with Maven 2?

前端 未结 9 875
日久生厌
日久生厌 2020-12-12 22:11

I\'m using Google Protocol Buffers to generate some Java classes for my project. Using Maven 2 and its \"antrun\" plugin, these classes are freshly generated before compile,

相关标签:
9条回答
  • 2020-12-12 22:41

    What you should see in your project explorer is a container named "Maven Dependencies" in place of the usual "Referenced libraries". This means m2eclipse is managing your build path.

    In my case, to achieve this, I checked "Include Modules" and unchecked "Skip Maven compiler plugin when processing resources" on the "Maven" section of Project->Properties.

    0 讨论(0)
  • 2020-12-12 22:43
    1. Right-click project and select Properties
    2. Choose Java Build Pathfrom the left and select the Source tab
    3. Click Add Folder
    4. Select the bin directory and click OK
    5. (project/target/generated-sources/xxxx) Click OK and Refresh the project
    0 讨论(0)
  • 2020-12-12 22:44

    m2eclipse doesn't support this. You must manually add the folder target/generated-sources as a source folder. When you tell m2eclipse to "Update Project Configuration", this will be overwritten and you have to restore it.

    Also, make sure that Eclipse looks for changes in the workspace.

    There might be some issues, though. Eventually, you'll run into errors that some class can't be compiled because some other class can't be resolved. Code completion will work, though. The root cause of this issue is that Eclipse gets confused when Maven changes class files in target.

    To solve this, you must tell Eclipse to compile to a different place than Maven.

    0 讨论(0)
提交回复
热议问题