Eclipse automatically adds wrong dependencies into pom.xml
Asked Answered
C

1

10

During work in my Maven controlled java project in Eclipse sometimes strange dependencies are added into the pom.xml of the project (scala.lang or whatever). Most often I realize this when committing my changes to source repository (and sometimes I don't realize it).

I use Spring Source Tool Suite 3.5.1, based on Kepler 4.3.2, installed Maven Integration for AJDT from Sonatype.

Possibly there is some automatism by Eclipse when it auto-determines imports in a source file, that it adds dependencies into the pom.xml. Can I disable this undesired behavior?

Cent answered 17/9, 2014 at 10:17 Comment(1)
I believe you are talking about STS 'Jar Type' content assist added in STS 3.5.0 [1]. When you get a content assist suggestion for a type in a spring project, STS will include types from common jars that are on typical spring project's classpath. They will have distinct 'jar' icons and a explanation that tells what thing it will add to your pom. Maybe its a bit too easy to add dependencies accidentally. However, this is not an answer to your question, I'll leave that below. But I thought maybe this is useful background info. [1] docs.spring.io/sts/nan/v350/NewAndNoteworthy.htmlNovokuznetsk
N
12

Yes, it can be disabled. Go to "window >> Preferences >> Java >> Editor >> Content Assist >> Advanced". Uncheck the 'Jar Type Search' content assist provider in both lists and press 'OK'.

Novokuznetsk answered 18/9, 2014 at 16:11 Comment(1)
Since I've been getting too many SO points for this answer... we have now added a little popup dialog in STS 3.8.0 so that you get an extra 'confirmation' before pom is modified. Also... it offers to disable the feature. See docs.spring.io/sts/nan/v380/NewAndNoteworthy.html under the heading 'JAR type search now asks for confirmation'Novokuznetsk

© 2022 - 2024 — McMap. All rights reserved.