簡體   English   中英

從Spring Boot應用程序導出jar並部署到ubuntu服務器

[英]exporting jar from spring boot app and deploy to ubuntu server

我已經開發了一個spring-boot應用程序,我想將此應用程序部署在ubuntu服務器中,但是當我嘗試導出jar文件並在我的PC中對其進行測試時,它不起作用,這是我的應用程序類

@SpringBootApplication
@EnableScheduling
public class Application extends SpringBootServletInitializer{

     @Override
        protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
            return application.sources(Application.class);
        }

    public static void main(String[] args) {
        // TODO Auto-generated method stub
          SpringApplication.run(Application.class, args);
    }
}

這是我的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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>geekycoders_my_team</groupId>
  <artifactId>geekycoders_my_team</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <name>geekycoders_my_team Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <properties>
      <start-class>com.geekycoders.my_team.Application</start-class>
</properties>
  <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.1.RELEASE</version>
</parent>
<dependencies>
       <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

     <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-security</artifactId>
</dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-websocket</artifactId>
    </dependency>
     <dependency>
       <groupId>mysql</groupId>
       <artifactId>mysql-connector-java</artifactId>
        <version>5.1.6</version>
     </dependency>
      <dependency>
    <groupId>org.thymeleaf</groupId>
    <artifactId>thymeleaf-spring3</artifactId>
    <version>3.0.3.RELEASE</version>
</dependency>

<dependency>
  <groupId>org.apache.commons</groupId>
  <artifactId>commons-lang3</artifactId>
  <version>3.5</version>
</dependency>

 <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>angularjs</artifactId>
            <version>1.5.9</version>

        </dependency>
        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>bootstrap</artifactId>
            <version>3.3.7</version>

        </dependency>
      <dependency>
    <groupId>org.json</groupId>
    <artifactId>json</artifactId>
    <version>20140107</version>
</dependency>
<dependency>
  <groupId>joda-time</groupId>
  <artifactId>joda-time</artifactId>
  <version>2.9.7</version>
</dependency>
</dependencies>


  <build>
  <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>

            </plugin>


        </plugins>
    <finalName>geekycoders_my_team</finalName>
  </build>
</project>

我將項目導出為帶有Eclipse的Runnable Jar文件,當我嘗試使用java -jar執行時,顯示錯誤

2017-03-26 16:30:55.376 ERROR 7819 --- [           main] o.s.boot.SpringApplication               : Application startup failed

org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [com.geekycoders.my_team.Application]; nested exception is java.lang.IllegalArgumentException: No auto configuration classes found in META-INF/spring.factories. If you are using a custom packaging, make sure that file is correct.
    at org.springframework.context.annotation.ConfigurationClassParser.processDeferredImportSelectors(ConfigurationClassParser.java:520) ~[footnet.jar:na]
    at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:184) ~[footnet.jar:na]
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:308) ~[footnet.jar:na]
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:228) ~[footnet.jar:na]
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:270) ~[footnet.jar:na]
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:93) ~[footnet.jar:na]
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:686) ~[footnet.jar:na]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:524) ~[footnet.jar:na]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[footnet.jar:na]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:737) [footnet.jar:na]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:370) [footnet.jar:na]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) [footnet.jar:na]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162) [footnet.jar:na]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151) [footnet.jar:na]
    at com.geekycoders.my_team.Application.main(Application.java:22) [footnet.jar:na]
Caused by: java.lang.IllegalArgumentException: No auto configuration classes found in META-INF/spring.factories. If you are using a custom packaging, make sure that file is correct.
    at org.springframework.util.Assert.notEmpty(Assert.java:276) ~[footnet.jar:na]
    at org.springframework.boot.autoconfigure.AutoConfigurationImportSelector.getCandidateConfigurations(AutoConfigurationImportSelector.java:152) ~[footnet.jar:na]
    at org.springframework.boot.autoconfigure.AutoConfigurationImportSelector.selectImports(AutoConfigurationImportSelector.java:94) ~[footnet.jar:na]
    at org.springframework.context.annotation.ConfigurationClassParser.processDeferredImportSelectors(ConfigurationClassParser.java:512) ~[footnet.jar:na]
    ... 14 common frames omitted

大聲笑,我現在有一個非常相似的問題。

不確定是否有必要,因為如果安裝了很多ide彈簧插件,它們可能會為您完成工作,但是由於我們使用的是maven,所以我很確定您必須使用maven來構建項目,以便做對了。

如果您使用的是eclipse,請嘗試運行方式> Maven build ...>目標:打包 (或僅使用命令行對其進行打包)

至少那是我通常所做的。 但是我在Maven的錯誤和問題上記錄很長,從不真正想花費更多的時間來學習似乎如此...不穩定的東西。(一旦我的所有依賴項在一夜之間損壞了,我不得不重新下載其中的三個修復所有LOC標頭錯誤的時間)因此,如果這對您不起作用,請不要感到驚訝。

這不是一個真正的答案,但是在我有50個代表之前,stackoverflow不會讓我發表評論。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM