现有的Maven项目可以添加SpringBoot框架吗

新手上路,请多包涵

我在 Eclipse 中有一个 Maven 项目,现在我需要添加数据库连接。我的教科书用 Maven 做了所有的 json 教程。现在,在关于 JDBC 的这一章中,他们使用的是 SpringBoot。

我可以将项目转换为 SpringBoot 吗?或者启动一个 SpringBoot 并导入我以前的 Maven 类。

原文由 SSI 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 353
1 个回答

这里描述 了如何将 maven 用于 SpringBoot 项目。

您将需要修改现有的 pom.xml 添加类似这样的内容以使其成为 SpringBoot 项目:

 <!-- Inherit defaults from Spring Boot -->
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.2.2.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>

原文由 Simulant 发布,翻译遵循 CC BY-SA 3.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题