繁体   English   中英

如何从现有的Maven项目创建Spring Boot项目

[英]How to create spring boot project from existing maven project

我已经在Eclipse中创建了一个Maven项目,我想将其部署在服务器上(我猜是tomcat)。 我相信可以通过Spring Boot来完成。 我的问题是:此项目已导入位于我的PC上的多个jar文件,并且在其构建路径的工作区中还有另一个项目。 我担心在集成过程中(将其转换为Maven)我可能会丢失所有依赖项。 通常,将jar文件导入到项目中的最佳方法是什么?如何在其构建路径中添加另一个项目? 请用您需要的任何其他规格发表评论。

这是pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" 
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>org.apache.jena</groupId>
  <artifactId>jena-examples</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>Apache Jena - Code Examples</name>
  <description>A collection of example code illustrating uses of Apache Jena</description>
  <url>http://jena.apache.org/</url>

  <properties>
    <ver.jena>[3.1.0,)</ver.jena>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <organization>
    <name>Apache Software Foundation</name>
    <url>http://apache.org</url>
  </organization>

  <dependencies>
    <dependency>
      <groupId>org.apache.jena</groupId>
      <artifactId>apache-jena-libs</artifactId>
      <version>${ver.jena}</version>
      <type>pom</type>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.10</version>
      <type>jar</type>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>commons-cli</groupId>
      <artifactId>commons-cli</artifactId>
      <version>1.2</version>
    </dependency>
    <dependency>
        <groupId>com.mashape.unirest</groupId>
        <artifactId>unirest-java</artifactId>
        <version>1.4.9</version>
    </dependency>
    <dependency>
      <groupId>org.apache.httpcomponents</groupId>
      <artifactId>httpclient</artifactId>
      <version>4.3.6</version>
    </dependency>
    <dependency>
      <groupId>org.apache.httpcomponents</groupId>
      <artifactId>httpasyncclient</artifactId>
      <version>4.0.2</version>
    </dependency>
    <dependency>
      <groupId>org.apache.httpcomponents</groupId>
      <artifactId>httpmime</artifactId>
      <version>4.3.6</version>
    </dependency>
    <dependency>
      <groupId>org.json</groupId>
      <artifactId>json</artifactId>
      <version>20140107</version>
    </dependency>
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-lang3</artifactId>
        <version>3.8</version>
    </dependency>
    <dependency>
     <groupId>org.glassfish.jersey.core</groupId>
     <artifactId>jersey-client</artifactId>
     <version>2.8</version>
 </dependency>
 <dependency>
     <groupId>org.glassfish.jersey.media</groupId>
     <artifactId>jersey-media-json-jackson</artifactId>
     <version>2.8</version>
 </dependency>
 <dependency>
        <groupId>com.github.galigator.openllet</groupId>
        <artifactId>openllet-owlapi</artifactId>
        <version>2.6.4</version>
    </dependency>
    <dependency>
        <groupId>com.github.galigator.openllet</groupId>
        <artifactId>openllet-jena</artifactId>
        <version>2.6.4</version>
    </dependency>
  </dependencies>

</project>

我认为您对spring.boot的实际含义有些误​​解。

Spring-boot是一个完整的生态系统,用于构建与许多常用Java库集成的微服务。

您的pom接缝是一个完全编写的应用程序,可以部署到空的tomcat服务器上。 Spring-boot不是一个空的tomcat,spring-boot是一个在后台使用tomcat的应用程序/框架。

您需要转到http://tomcat.apache.org/并下载tomcat服务器,然后在您选择的IDEA中搜索如何设置/启动tomcat。 完成之后,您需要在所选的IDEA中打开maven项目,并将其部署到tomcat服务器。

使用eclipse / intellij,互联网上有几本教程介绍了如何安装和设置tomcat。 还有大量有关如何导入Maven项目以及如何构建和部署到tomcat的教程。

要在您的Maven项目中集成本地jar文件,请查看: 如何将本地jar文件添加到Maven项目?

要将Spring Boot添加到pom.xml,您需要添加以下内容( 来自该文档

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM