Can I convert Maven Project to SpringBoot

后端 未结 5 813
滥情空心
滥情空心 2021-02-06 00:00

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

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-06 00:54

    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 :-

    
    
        org.springframework.boot
        spring-boot-starter-parent
        1.4.7.RELEASE
    
    
    
    
        
            org.springframework.boot
            spring-boot-starter-web
        
    
    
    
    
        
            
                org.springframework.boot
                spring-boot-maven-plugin
            
        
    
    

    • 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

提交回复
热议问题