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
Related
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)
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
I'm trying to do this getting started guide from Spring. So I cloned the project using git from the command line. As I'm working with Gradle, I removed the Maven files from the repository to clean the project.
After that I open my STS and go to File -> Open Projects from File System and navigate to the /initial folder of the repository. The project is imported correctly but when I try to add some "java stuff" (packages, classes, etc.) I get several errors and I can only add folders and files, which is quite annoying for working.
To be more descriptive, I'll add some images so you can see what's happening. This is the project initially imported into STS as I described above:
Then I try to add some java stuff, let's say for example a source folder. So Right Click on library -> New -> Source folder and this is the result:
And in the properties of library I have the following:
So the question is: how can I tell to STS to recognize the library folder as a Java Project (or Gradle module, I don't know how to call it) instead of a plain folder so I can add my packages and classes?
Thanks in advance for your answers.
In case you would like to work with Gradle, you should use the Gradle integration for Eclipse (project Buildship) and install that into your STS environment. After that, you should be able to import the projects either from disc as existing Gradle project (not as file system) or via the wizard that integrates the spring guides into STS (Import Getting Started Content). The wizard for the guides also let you choose between the Maven and the Gradle variant, so you don't need to close and delete stuff yourself.
Hope this helps!!!
I have a project that is using custom spring-boot-starter. The way I understand is that for every starter we have to create META-INF folder and add spring.factories file to it and then add AutoConfiguration class.
It was working fine. But all of a sudden it stopped working. Then I had to remove the META-INF folder again and add it back and then it started working again. Is there something I am missing here?
My bad but for people who might run into issues. If you are using maven to build your projects do remember to include **/*.factories in the your pom under build
I have a normal Netbeans project, and I would like to add the source packages of this project to a project that is a Maven Web Application, also within Netbeans.
I tried copy-pasting the packages into the /src project directory of the Maven application, but this doesn't seem to work.
Could someone please tell me how I could do this ?
If this is not possible, could someone tell me if I can convert the entire normal project into a Maven Web Application ? Thank you :)
It sounds like you need to add the dependency to your web-application instead of the source code, cause maven is intended to handle exactly such situations.