Eclipse中无法通过Ctrl+Click下载CrudRepository源码——源码未找到
I’ve run into similar frustrating issues before with Eclipse not pulling in source jars automatically, even when STS works flawlessly. Let’s walk through targeted fixes that usually resolve this:
Verify Eclipse’s core source download settings
Head toWindow > Preferences > Maven > Download Sourcesand ensure the "Download Artifact Sources" checkbox is ticked. Also, checkWindow > Preferences > Java > Editor > Hyperlinkingto confirm "Open Declaration" is enabled—this is what powers the Ctrl+Click navigation to declarations.Force a full Maven dependency refresh
Right-click your project →Maven > Update Project. Check the box for "Force Update of Snapshots/Releases" and hit OK. This tells Eclipse to ignore cached dependencies and re-fetch everything, including source jars, from scratch.Manually attach the source if automatic download fails
If the above doesn’t work, locate thespring-data-jpajar under your project’sMaven Dependenciesfolder. Right-click it →Properties > Java Source Attachment. You can either point it to a manually downloaded source jar or let Eclipse search for it via the "Workspace..." option.Clean and rebuild your project
Corrupted build artifacts often mess with source linking. Go toProject > Clean..., select your project, and click OK. Then runmvn clean installvia the Maven build menu to rebuild everything fresh.Check for workspace metadata corruption
Sometimes Eclipse’s workspace metadata gets wonky. If all else fails, back up your workspace, delete the.metadatafolder, restart Eclipse, and re-import your project. This is a last-resort fix but often clears persistent issues.
Also, double-check your pom.xml has the correct Spring Data JPA dependency (it should inherit from the Spring Boot parent if you’re using that, but confirmation never hurts):
<dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-jpa</artifactId> </dependency>
内容的提问来源于stack exchange,提问作者ASharma7

