2017-03-26 48 views
0

我已经开发了一个春季启动应用程序,我想在ubuntu服务器上部署这个应用程序,但是当我尝试导出jar文件并在我的电脑中测试它不起作用 这是我的类应用从春季启动应用程序导出jar和部署到Ubuntu服务器

@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> 

我的项目作为运行的JAR文件导出,用eclipse,当我尝试用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 
+0

使用Spring Application.class中的包添加批注@ComponentScan然后尝试。 – Ajinkya

回答

-1

大声笑,我现在有一个非常类似的问题。

不知道是否有必要,因为有大量的ide spring插件可以为你做这项工作,如果你安装了它们,但由于我们使用的是maven,所以我很确定你将不得不与你的项目一起构建maven为了做正确的事。

如果你使用eclipse尝试像运行方式> Maven构建...>目标:包

至少这就是我通常做的(或只是使用命令行打包)。但是我长期记录了Maven的错误和问题,从来没有想过要花更多时间学习看起来如此不稳定的东西(一旦我所有的依赖关系都在一夜之间被损坏了,我不得不重新下载其中的三个时间来解决所有LOC标题错误)所以不要惊讶,如果这不适合你。

没有真正的答案,但stackoverflow不会让我评论,直到我有50代表。

相关问题