Setup SpringBoot in IDEA from Initializr - spring-boot

I don't understand what happens (before everything worked, feels like I've lost some settings somehow). I download archive from initializer (spring.io; doesn't matter which dependency include, let's say only Spring Web), extract from archive and open project from IDEA. First of all, I'm receiving file ***.iml outside of the container (before it is automatically was created inside)
Also now I have to Assign to "java" folder MarkDirectoryAs - SourceRoot by hand (before this staff applied authomatcally).
And finally looks like IDEA does not see the itself downloaded dependencies. When the project just opened I receive this:
How can I fix it?
UPD:
Errors after reload
And Libraries do not have Maven...
Also what I've found out, I have an error with link to local repository and do not have link to external (like in previous projects)
don't know how to fix it.
Also in my Maven only Lifecycle folder presented now.

Maven Home Path choose as shown on the pic. (Settings->Build,Execution,Deployment->Build Tools->Maven)

Related

Classpath root pointing to grails-app/views - how to amend?

My goal is to add some Json files as project resources accessible from the code. The solution must work in IntelliJ and deployed in a Tomcat. I don't mind if the files are located under grails-app/conf or src.
Getting my classpath root using one of
grailsApplication.parentContext.getResource("classpath:") or
grailsApplication.parentContext.getResource("classpath:.")
resolves in $MY_APP/grails-app/views
However, trying to navigate from this root to grails-app/src using
grailsApplication.parentContext.getResource("classpath:..")
results in: "java.io.FileNotFoundException: class path resource [..] cannot be resolved to URL because it does not exist". This might be acceptable since a root is a root, I guess.
How can I extend my classpath to folders outside of grails-app/views?
How can I make sure that the solution works in both, IntelliJ and Tomcat deployment?
I'm using Gradle 3.5, Grails 3.3.11, Groovy 2.4.10. I'm working in IntelliJ. Rebuilding the project using the Gradle view has not helped so far. The project setup consists of
grails-app/conf/application.yml
grails-app/conf/application.groovy
grails-app/conf/ApplicationResources.groovy (I've tried to add a resource entry here and rebuild the project)
... (Please feel free to have a look in the project in case of further config detail questions.)
I've been exploring endless questions and answers of similar "how can I add my file to the classpath" questions, but nothing has helped so far.
As mentioned earlier in the comment, that you should put the JSON files under /src/main/resources folder. And, you should be able to access the files as:
getClass().getResource("/example.json")
Here is an example application
#PuneetBehl's answer helped me realizing that it isn't about the project code configuration. It is about the configuration of my IDE, which is IntelliJ. You can set Project Structure... --> Project Settings --> Modules. There, "Resource Folders" on the right hand side was listing as: "conf", "i18n" and "views". I dont know why IntelliJ chose "views" for the path "/.".
Anyway, it was enough to:
use Puneet's proposed syntax: getClass().getResource("/myfolder/example.json")
after I had created grails-app/conf/myfolder/example.json

IntelliJ IDEA does not recognize spring boot project

I have a Spring boot project and, until yesteday, IntelliJ IDEA (ultimate version) was recognizing its structure perfectly. I've downloaded the project again from a git repository and now it looks like a bunch of random files...
As example, it does not recognize when a directory tree is a package and I have to pass through all the folders (before it was recognized as a package).
How can I restore the previous setting? I don't think I changed anything... on purpose at least.
Thanks
EDIT:
I'll share a screen of the problem now: the test folder looks like a regular directory and does not recognize the spring code

maven parent artifactId not updating in IntelliJ project view and File - open recent

I have renamed the parent module in my maven project by changing its artifactId. I also updated all parent-artifactIds in the child modules accordingly. My problem is that even though i rebuilt the maven project (clean install, which worked) and reimported all Maven projects and restarted IntelliJ, the old artifactId is still displayed in the project view.
Have I missed something in order for IntelliJ to update the name? How can I fix the problem?
edit:
After following the instructions in the link of CrazyCoder, the new name is displayed correctly in the project view. I will write an answer to describe what I have done.
But I have noticed another problem now: In File -> Open recent the old artifactId is still displayed. I have not found where I can access what is displayed in this menu to rename it. The issue is resolvable by cloning the repository with git again. Is there also a way to fix this in IntelliJ?
This is a very long known issue and can be resolved following these steps:
Change the artifactId in your poms wherever it is necessary
Run Clean-Install on your project to be sure everything is still working
Right Click on the project -> refactor -> rename or Shift-F6 and change the module name to match the new artifactId
The .iml file should be updated as well now. It might be that your IDE is confused now. Go to File and click Invalidate Cache/Restart
IntelliJ should now be displaying the correct name in the project view. According to my sources it could be necessary to update the names of the directories manually, which would be necessary between step 2 and 3. I did not have to do this, but still wanted to mention it if someone runs into that problem.
Another issue is that in Open Recent the old artifactId is still displayed. This is solvable by cloning the repository with git again. Unfortunately I have not found a way to do this in IntelliJ.

Maven JavaFX Cannot find Main Class

I have some problems running my JavaFX8 Project with Maven. Here is the situation:
I create a Maven Java FX application within Netbeans (File --> New Project --> Maven JavaFX Application). Netbeans creates the packages and also creates a MainApp.java file.
Even if I don´t edit anything in this project, I get an error/warning within the properties.
Location: Right-Click Project --> Properties --> Run
Message: One of Run/Debug/Profile Project actions has been modified and the Run panel cannot be safely edited
The project can be built and run for some time, but after I create more packages, classes and stuff like that, I can´t run the application anymore.
It tells me, that it can´t find the Main class.
Message: Error: Could not find or load main class
I found some entries at stackoverflow and google, but none of the solutions seem to work for me.
I read this Topic for example.
One of the solutions is, to set the main class at the properties (Run), but all the fields are disabled. I also deleted the Cache, which didn´t solve the problem. I also checked the typing.
Some other sites stated, that it seems to be a bug, but they had older Netbean Versions. I updated my Netbeans version to 8.2 today.
The only solution at the moment is to create a new Maven JavaFX project and refactor the files to the new project. This works for a couple of hours but in the end the error occurs again.
Does anybody know a solution?
Use Run from the Project, not Run File from the main file. The latter can work on other setups, but not straight out of Maven.

using pom.xml instead of iml files in idea

We are using IntelliJ idea in order to develop our product.
till now, we saved the iml/ipr files in a version control in order to share the same configuration among developers (and also between different versions of our product).
however, since idea changes those iml files a lot, it is an exhausted task to resolve its conflicts, and actually feels a bit wrong.
Moreover, idea 15 is no longer checks-out iml/ipr automatically.
I tried the maven-idea-plugin which suppose to generate the iml/ipr based on the pom.xml and it looks promising (except for some minor issues) but it's obsolete and there many stackoverflow posts advise against it.
I also undestand that the "correct way" to load our project is by loading the e pom.xml directly in idea.
The problem with that loading the pom.xml is that each user has to reconfigure idea (such as exclude directories, set the run configuration, plugins, maven version, JDK location etc.)
every time he download the code from the version control, which happens quite often.
So, my question is what is the best way to use intellij idea with our project.
my goal is that once a developer download the code he will be able run idea without manually configure a thing.
Thanks,
Meir
I am using Intellij 15.0.3 Community edition.
In our current project we do not add *.iml to Git.
For shure we do add pom.xml to Git.
I did not add any special plugins or configure idea in the way you described
(such as exclude directories, set the run configuration, plugins, maven version, JDK location etc.)
So I am using Idea out of the box, only the plugin 'Maven integration' is activated. I initially cloned the Git repository in a new folder.
In Idea I choosed File| New | 'Project from existing sources '
and selected the folder with the pom.xml.
Thats all, works perfectly. I can build in Idea or on the command line.
I can use Git in Idea or on the command line.
Everything works perfect.
So I can asure you that its absolutely possible without having *.iml under version controle.

Resources