繁体   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