Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I convert Maven Project to SpringBoot

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.

like image 803
SSI Avatar asked Mar 31 '15 04:03

SSI


1 Answers

Convert Maven Project to SpringBoot

  • Ist option :Spring Boot Using parent POM

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>

  • 2nd option:Using Spring Boot without the Parent POM

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

like image 154
NeeruKSingh Avatar answered Sep 21 '22 18:09

NeeruKSingh