使用Spring Boot创建一个库jar [英] Creating a library jar using Spring boot

查看:102
本文介绍了使用Spring Boot创建一个库jar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个具有REST Web服务和jpa依赖项的spring boot应用程序.该应用程序可以作为独立应用程序独立运行.我正在尝试使用vaadin作为使用sring引导项目中的服务的单独项目来添加UI层.有没有一种简单的方法可以将Spring Boot应用程序制作为可以包含在其他项目中的库jar.

I created a spring boot application having REST web services and jpa dependencies. The application runs on its own as a standalone application. I'm trying to add UI layer using vaadin as a separate project that uses the services from the sring boot project. Is there an easy way to make the spring boot application as a library jar that can be included in other projects.

我在论坛上搜索,发现一些建议不要使用spring boot而是使用spring框架创建库的线程.只是想检查是否有任何示例可以在Spring启动中完成.

I searched the forum and found some threads that advised not using spring boot but instead using the spring framework to create the library. Just wanted to check if there are any examples how this can be done in Spring boot.

推荐答案

我的这个项目使您感兴趣.我已经使用Spring-Boot制作了一个可以在其他项目中使用的库.

This project of mine may be of some interest to you. I have used Spring-Boot to make a library to be used in other projects.

这里要注意的主要事情是:

The main thing to note here is to have:

@SpringBootApplication(scanBasePackages = {"me.ramswaroop.jbot", "example.jbot"})

在启动spring-boot应用程序的主类中的

.参见此主类了解更多.但是老实说,根据我的看法,使用Spring-Boot来使一个库包含在其他项目中不是一个好选择.如果我要重写 JBot ,那么我肯定不会以这种方式使用Spring-Boot.

in the main class where you start the spring-boot application. See this main class to learn more. But to be honest, using Spring-Boot to make a library to be included in other projects isn't a good choice according to me. If I were to rewrite JBot then I wouldn't have used Spring-Boot this way surely.

Spring-Boot 对于创建一个可以运行"的独立应用程序确实非常好,但是不确定,请创建一个库.我认为图书馆应尽可能少地依赖.

Spring-Boot is really good to create a stand-alone application that you can "just run" but to create a library, hmm, not sure. I think a library should have fewer dependencies as possible.

这篇关于使用Spring Boot创建一个库jar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆