I have a Maven Project in Eclipse and now I need to add database connectivity. My textbook did all json tutorials in Maven. Now in this chapter on JDBC they are using SpringBoot.
Can I convert the project to SpringBoot? Or start a SpringBoot and import my previous Maven classes.
Convert Maven Project to SpringBoot
Add following dependencies in pom.xml file**:-
1.) Inheriting the starter parent(spring-boot-starter-parent): spring-boot-starter-parent is a special starter that provides useful Maven defaults.
2.) spring-boot-starter-web :- Starter for building web, including RESTful, applications using Spring MVC. Uses Tomcat as the default embedded container.
3.) spring-boot-maven-plugin:- Spring Boot includes a Maven plugin that can package the project as an executable jar.
here is pom.xml :-
<!-- Inherit defaults from Spring Boot --> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.4.7.RELEASE</version> </parent> <!-- Add typical dependencies for a web application --> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies> <!-- Package as an executable jar --> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build>
Not everyone likes inheriting from the spring-boot-starter-parent POM. You may have your own corporate standard parent that you need to use or you may prefer to explicitly declare all your Maven configuration.
If you do not want to use the spring-boot-starter-parent, you can still keep the benefit of the dependency management (but not the plugin management) by using a scope=import dependency, as follows:
< dependency> < !-- Import dependency management from Spring Boot -->
< groupId>org.springframework.boot< /groupId>
< artifactId>spring-boot-dependencies< /artifactId>
< version>2.0.0.BUILD-SNAPSHOT< /version> < type>pom< /type>
< scope>import< /scope> < /dependency>
Fore more details find here in Spring Boot Docs:- https://docs.spring.io/spring-boot/docs/1.4.7.RELEASE/reference/htmlsingle/#getting-started-maven-installation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With