Adding JPA support to an existing Maven project in IntelliJ - maven

I've been working on a project in IntelliJ for a while now using Maven (My god, maven is cool!). For the persistence I wanted to use JPA.
The issue is that I'm not sure how I can enable JPA support for my existing project, following this guide didn't work since my code still can't use tags such as #Entity.
It looks like IntelliJ is adding a new package (?) for JPA that my existing code can't access. Here's my package structure:
My existing code is in the src directory, while IntelliJ created the JPA directory for JPA.
Is there something I can do to add JPA to the existing code, or should I move my existing code to the JPA directory? I would like to keep using Maven.
Thanks!

while IntelliJ created the JPA directory for JPA.
it's weird. IDEA sholdn't create new source module if you just try to add JPA support to existing code.
Try to add JPA facet to your existing module via Project Settings

File--> Project Structure --> Facets --> click on + --> Select JPA

Related

How to add code template which will be available to be added later to my later spring boot projects readily?

i want to create a setup in which i have template code(s) which when starting a new spring boot project can be easily added into the new project.
I tried finding stuff on net which mostly showed adding a custom service or a dependency in the project.
You can create a Spring Boot project that contains nested maven projects is called the multi-module project. this approach give you option to add or remove module (addon project or template)

Converting existing project to Spring boot project in InelliJ

I have an existing project. I need to make it a Spring boot based project and I am using IntelliJ CE.
What would be correct procedure for doing it?
Edit:
Project has no initial structure. It is a totally empty project. So no existing modules etc.
Spring Boot is an Ultimate feature, so first you would need to try/buy the IntelliJ IDEA Ultimate.
From there, you can add Spring support to existing project modules or use the Spring Initializr wizard to select the necessary configuration when creating a new project or module.
In your maven pom.xml or build.gradle file, I would add the spring boot starter dependency:
spring-boot-starter (the group id is org.springframework.boot)
If the application is a web application, I would also add the web starter spring-boot-starter-web also with the same group id (org.springframework.boot)
For convenient features, applying the spring boot plugin would help in creating a runnable jar with all required dependencies bundled called a fat jar.
A great tool I use is the spring boot project generator. It allows you to configure the modules you want and create a project template.
Spring Boot requires IntelliJ IDEA Ultimate. If you want to use IntelliJ CE, please create a project using Spring Initilizer then import the same to your IntelliJ CE (File -> Open -> Choose the project root folder). After you import the project, wait for some time so that IntelliJ can download the dependency and build your project. You can check from (Build -> Build your project). Then find the main class of spring boot and run it using the green play button

MongoDB dependency for spring

I am a beginner to mongodb and spring, so I apologise if the question is silly.
I want to use mongodb in my spring application. I created a maven project, what dependencies do I need to add in my pom.xml file.
I can see some jars like spring-boot-starter-data-mongodb is added but can find no explantions about it. What does it do exactly?

What is a general way to use a Spring project inside another?

I have a Spring project which is a regular jar file. It uses JPA and Spring Data.
I'd like to use it in another Spring project, which is a war running in Tomcat. It also uses JPA and Spring Data.
I have installed the jar into the local maven repository, and have declared it as a dependency in the parent project.
What do I need to do to make them work together correctly?
Are there naming conventions for the various context, properties, and persistence files?
Do I need to import the library configuration files in the "parent" configuration files?
I am getting the following error when trying to run the parent:
IllegalArgumentException: Not an managed type: class [some domain class in the parent project]
Use Maven Modules. Reference here:
http://books.sonatype.com/mvnex-book/reference/multimodule.html

Pulling out domain classes from a Spring Roo project

We need to be able to pull out domain classes (i.e. entities) from a Spring Roo project in order to reuse them for a Spring Batch project.
Is this possible?
Bearing in mind that we rely on Maven as our build and dependency management tool, and that our Roo project is already created, can we switch to a multi-module architecture?
If so how?
I don't think there is a roo command for converting a single module maven project to a multi module project.
One option would be to use roo to create a separate persistence module in your current project and manually migrate your entities and configuration over.

Resources