STS unable to bind maven file (.m2) - spring

I'm working on a maven project in Spring tool suite(STS), issue is unable to navigate to other classes and methods (using ctrl+ mouse click), and its showing many error messages near import statements and other places in the class.
When clicked on the red cross mark which states error and select FIX project setup below is the message displayed on popup window.
The following proposals have been found to fix the unresolvable reference to 'Bootstrap'
Add archive 'lpa-core-1.2.5.jar - c:\Users\tom.m2\repository\com\lpa\lpa-core\1.2.5' to buildpath of 'lpa-realtime-service'
Please suggest how to include .m2 file automatically while build process to avoid the error messages and to navigate to other classes and methods using ctrl and mouse click.

It sounds like your project is not properly set up so that the IDE doesn't really configure its classpath correctly. Normally this would all happen automatically via m2e (i.e. Eclipse's maven support).
M2e is included in STS by default, so its probably installed, but somehow your project isn't treated as a maven project.
You can try to re-import it using the proper 'import wizard' which should set things up correctly for you.
Steps:
Delete the project from the workspace. Take care not to actually delete the files themselves. (There's a checkbox 'Delete project contents on disk', so don't select that).
clean out all the 'junk' data from your project. Delete all tese files / folders from your project .classpath, .project, .settings, target.
Now that you have a 'clean slate'. Import it using m2e. Menu: File >> Import >> Existing Maven Projects".
This should setup everything correctly.
I say should because it depends to a large degree on what is in the project itself. But this, in principle, is the correct way to import maven project into STS (or Eclipse in general).

Related

Intellij - adding another SpringBoot project

I have generated two Spring Initializer Maven projects. I open the first one with File-Open-location_of_the_file, It opens up the project, when I want to open the second project it closes the previous project. I want to be able to see both projects in the project window.
I don't want the program to open a second IntelliJ window, I just want them to be inside the same window, same file explorer inside IntelliJ.
I have both projects in the /documents/microservices folder.
I'm relatively new to IntelliJ, help would be greatly appreciated.
Use Import Module action: File | New | Module from Existing Sources.
See Import an existing module documentation for more information.
I solved this issue by doing this:
View -> Tool Windows -> maven -> + "Add maven projects" -> find the pom.xml from the project and then it adds it to your file explorer.

How can I remove a dependency from IntelliJ which I added through pom.xml?

I added Spring Security to my dependencies in the pom.xml and IntelliJ IDEA then downloaded it. I checked the http://localhost:8080 and got redirected to http://localhost:8080/login.
I now want to remove the dependency I added. I removed the dependency from the pom.xml but the login page is still there, and I can still see it in IntelliJ in the dependencies of Maven.
How can I completely remove the dependency?
When you made the change to pom.xml, a popup probably would have appeared at the bottom-right of the IDE saying:
Maven projects need to be imported
Import Changes       Enable Auto-Import
If you click 'Import Changes', you should find that IntelliJ reloads the POM file and removes the dependencies that you've deleted.
Assuming you no longer have that popup on the screen, you can achieve the same thing by opening the 'Maven' tab on the right-hand side of the screen and clicking the 'Reimport All Maven Projects' button (looks like a refresh button with two arrows in a circle).
You can also have IntelliJ do this for you automatically. If the popup mentioned above is still open, simply click 'Enable Auto-Import', otherwise open the settings and navigate to:
Build, Execution, Deployment > Build Tools > Maven > Importing
then select the option "Import Maven projects automatically".
IntelliJ IDEA caches files and dependencies.
Try to invalidate cache. as below -
Close intellij
Remove ...\home.IntelliJIdea14\system\Maven - cache for maven artifacts, you can
probably delete it.
Module and project informations are stored within the project - .idea folder and *.ipr
and *.iml files, you can delete them to be sure and reimport the project.
It is probably because it is loading the jar files from the cache location. You can clear that clicking on Reload All Maven Projects button present on the right hand section of screen, under Maven as shown in this screenshot.
Once it is done, rerun your project. It should work as expected.

Access to a source code a maven dependency

In Netbeans IDE we have an option for maven dependencies called "Download Sources".
After download we can see a package icon in right bottom of that dependency means it is downloaded
But still I cannot see any .java file?
Does the "Download sources" mean something other than .java files?
I tried to see source code of a JSON parser in java .If you know somewhere easy I wonder if you tell me in comments.
NetBeans downloads the jar file with the sources from Maven central. It doesn't store individual Java files directly.
To view the downloaded source, you can expand the library node, navigate to the class you are interested in, then double click on it (or right click, then choose "Open").
Another way to jump to the source code is, to use "Goto Source" inside the editor where you use the classes.

Intellij Idea hides my spring cloud contracts under test/resources

I have written my first spring-cloud-contract using Intellij Idea 2018.2. Everything works fine, but I cannot edit the contract from within Idea because it hides the complete src/test/resources/contracts folder in the project view. So I have to individually open each contract vi the file -> open... menu.
Can anybody tell me how I can access my contract files in Idea from the project view?
I have the same problem with maven. It enough to refresh the project and the folder will be added to the classpath

Xcode how to add an external project

I need to add an external project to my Xcode project, the reason for this is I need to add a Target Dependency on that external projects static library.
I can't seem to add it in the way I need, I would like it like this:
However, when I add another project to my actual Xcode project I get the following which doesn't let me explore that project from my one and so I can't add the dependency I need.
Note that these screenshots are from two different projects, and in the one which is showing me what I want to reproduce in my own project, dragging in multiple projects works as expected.
Maybe I have some settings set up wrong in my project ? All I've done is take a template detail-master application from Xcode.
You did it right. The problem is that Xcode cannot have the same project opened twice.
Close Serenity.xcodeproj before reopening your parent project.
Yes, this is possible, it's called a workspace.
In your example:
Open both of your projects
Drag the Serenity project into the Dependant project
I think what you are doing wrong is dragging the Xcodeproj, try opening that project and dragging the project block instead (see pic)

Resources