Really removing a package from a Spring Boot / Maven / IntelliJ project - spring-boot

I'm building a web server using Spring Boot, Kotlin and IntelliJ and am learning a lot. I added Thymeleaf but decided later than it didn't meet my needs, removed it from the POM and rebuilt the project.
On startup, Thymeleaf was still looking for the /templates/ folder (which I'd also removed), even though Thymeleaf was no longer a part of the project, supposedly. A project-wide search (shift-ctrl-F) for thyme, case-folding, found nothing, so I closed the project and used the GNU find command-line utility to search for thyme in the project hierarchy. That found references in project.iml and some .xml files under .idea/libraries. I removed those, re-opened and rebuilt the project, and it no longer mentioned /templates/ or Thymeleaf on startup.
So my question is: what would have been the 'official' non-hacky way of removing the Thymeleaf package from my project? I am now wondering what other unwanted libraries are in the project, and how I should remove them.

Related

Same jar (name + version) but different code by maven

I have run into a really frustrating bug.
I have a dependency in my pom.xml file -> cd.connect.openapi.gensupport:openapi-generator-support:1.4
I have two completely different project.
Each having its own pom.xml and both require this dependency.
Now one project works fine.
But in another project, while debugging, I found that this exact same dependency has buggy code in this project but not in another.
In this project, this jar has a class called ApiClient.java, which uses a static initialiser block to populate a Map for exception handling. This block uses some constants define in Response.java. But there are to constants which it uses in ApiClient.java and these 2 dont exist in Response.java. Hence when I run the code, I get error NoSuchFieldError and sometimes I get NoClassDefFound.
I tried reloading maven project, deleting .m2 folder so that the dependency gets downloaded again, but no luck.
Any suggestions are welcome.
UPDATE
In Project that is not working
ApiClient.java -> cd.connect.openapi.gensupport:openapi-generator-support:1.4
Response.java -> javax.ws.rs.jsr-311 api
In Project that is working
ApiClient.java -> cd.connect.openapi.gensupport:openapi-generator-support:1.4
Response.java -> jakarta.ws.rs:jakarta.ws.rs-api:2.1.6
UPDATE-2
In project that is working, jakarta jar is present and javax is not. So ApiClient is using jakarta.
But in project that is not working, both jakarta and javax are present and it is using javax, hence the problem.
So question boils down to how can I make it to use jakarta one.
Will try deleting javax one, hopefully it wont break anythin else.

How to setup Maven to enable JSF2 resources versioning?

I have read the following essay:
Resources (library) in JSF 2.0
It's about versioning of web resources for JSF2 project.
May I know how could I do when my project is Maven-based? What need to be setup or added in the Maven setting?
Thanks a lot.
Effectively your question is a combination of three existing questions in Stackoverflow.
One is already superfluous since you already know how JSF versioning works, you just (unfortunately) referred an external site and not the existing question but from this question you need to 'remember' the format of the version number that needs to be used.
The second part should also not have been to difficult to come up with. JSF is a runtime framework and has no build/deploy time features. But you already use maven, so what is needed to build time copy(move?) the resources to a new location. The source folder can differ, it can be an additional resources folder e.g. src/main/myresources, that you don't treat as a resources (since it would end up in the classes folder then by default) or it can be a folder inside the webcontent and then you need to move (copy/delete). This is all for you to find out.
The third part is that the destination folder needs the version in the right format
1_0
1_1
1_2_3
Since this differs from the project version format, you need to search/replace this
which includes the project version in the right format. There are features for this as well in maven.
So you see, it all boils down to breaking a problem down into manageable parts...

How to create a Java EE 7 Maven IntelliJ Project

I am new to Stack Overflow because of my frustration to build a working Java EE 7 Project with Maven and IntelliJ ultimate.
I learned a lot about JPA and JSF in the last weeks and am thrilled to put my knowledge to use but unfortunately I am not able to create a working project structure as I get all sorts of errors along the way. I haven't found a single up to date tutorial which is working on the entire Internet.
My greatest achievement is creating a Maven project, and run the index page on a Jboss Wildfly (11) server.
I know Maven (3) requires a certain structure to work, I read that it is the one in picture 1.
Picture 1
Furthermore I know that I can add framework support by right clicking the project name and that I can add facets or modules by selecting files and project structure.
I would be very thankful if someone could explain the right creation of such a project. I already wasted double digit hours and lost a lot of fun.
I had to create a Maven Project with IntelliJ. After that I added JavaEE Application under Framework Support and checked the boxes for JSF and Web Application under Java EE aswell.
Now this doesn't work alone, I had to put this in the right structure Maven requires. I moved the META-INF Folder to main/src/resources. After renaming the web Folder to webapp, I moved it to src/main.
To check, go to Project Structure/ Facets and check if the paths are set correctly.
After adding a local Wildfly 11 Server Artifact (war), IntelliJ starts the default browser and I get to the index page.
The Project Structure
I recommend you take a look at JetBrains page, they have a lot of tutorials on how to use their products. Here how to create new Maven project:
https://www.jetbrains.com/help/idea/maven.html#maven_create_project
Also, here you have information how an example pom.xml file looks like and how to build it:
https://maven.apache.org/guides/getting-started/maven-in-five-minutes.html
When you develop your project you can add dependencies to the pom.xml file

question marks in project explorer and version errors in pom.xml using Spring STS for Jhpister generated application

I have generated spring-boot and angularjs based application using jhipster and imported as existing Maven Project in Spring STS.
The application is running fine but I did not understand what are those question marks (?) in the project explorer are? and also red marks in pom.xml for versions indicate?.
But still the application is running fine. I am not sure whether these issues cause problems in future and how can I get rid of them?
The question marks are coming from the version control integration and indicate that those files are not yet committed to version control.
The squiggle lines in the pom should reveal more information if you hover over them.

How can I update Spring and Hibernate libraries in NetBeans IDE?

Probably, it's a common and obvious issue, but I couldn't find the answer, so, a short tutorial or a link would be appreciated. My NetBeans has been recently updated, but if I create a new project, that uses Spring and Hibernate, the IDE provides options for Spring 3.0.2 (and even 2.5.6) and Hibernate 3.2.5. Of course, I could add manualy all the new libraries for each project, but it doesn't seem like a good idea. Just in case it's important, I use Ubuntu.
I think I've found a way to do that. In NetBeans's menu Tools/Libraries there are options for creating new libraries and adding its jar files or folders. I tried to add new Spring libraries (I didn't have a chance to put spaces in its name) and they appeared as an option of Spring MVC version when creating a new project.

Resources