2014-12-04 51 views
1

真是一个美好的一天,不是吗?Spring Boot - 应用程序未能以类路径启动

我希望这个社区的某个人能帮助我。

的Tomcat版本7, Servlet API的3.0

我喜欢用一个.war开始我春季启动项目在Tomcat。我的继承人弹簧引导应用的代码:

主类

@Configuration 
@EnableAutoConfiguration 
@ComponentScan(basePackages = "com.###.dashboard") 
@EnableJpaRepositories 
@EntityScan(basePackages = "com.###.dashboard.domain") 
public class Dashboard extends SpringBootServletInitializer { 

    public static void main(String[] args) { 
     SpringApplication.run(new Object[] {Dashboard.class}, args);  
    } 

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


} 

POM的Tomcat /弹簧引导的

<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>com.###.dashboard</groupId> 
    <artifactId>Dashboard</artifactId> 
    <packaging>war</packaging> 
    <version>1.0</version> 
    <name>Dashboard</name> 
    <url>http://maven.apache.org</url> 

    <parent> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-parent</artifactId> 
     <version>1.1.8.RELEASE</version> 
    </parent> 

    <dependencies> 

     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-web</artifactId> 
     </dependency> 

     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-mobile</artifactId> 
     </dependency> 

     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-thymeleaf</artifactId> 
     </dependency> 


     <dependency> 
      <groupId>com.h2database</groupId> 
      <artifactId>h2</artifactId> 
     </dependency> 

     <dependency> 
      <groupId>org.springframework.data</groupId> 
      <artifactId>spring-data-commons</artifactId> 
     </dependency> 

     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-data-jpa</artifactId> 
     </dependency> 

     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-tomcat</artifactId> 
      <scope>provided</scope> 
     </dependency>  

    </dependencies> 

    <properties> 
     <start-class>com.###.dashboard.main.Dashboard</start-class> 
    </properties> 

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


     </plugins> 
    </build> 

</project> 

错误消息

2014-12-04 13:32:18.878 INFO 198588 --- [   main] .b.l.ClasspathLoggingApplicationListener : Application failed to start 
with classpath: [file:/../tomcat7/webapps/dashboard/WEB-INF/classes/, ..path to libs, list of all jar files in folder libs.. 
2014-12-04 13:32:19.091 INFO 198588 --- [   main] ationConfigEmbeddedWebApplicationContext : Closing org.springframework. 
boot[email protected]61f0fe81: startup date [Thu Dec 04 13:32:15 CET 2014]; root of 
context hierarchy 
java.lang.reflect.InvocationTargetException 
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
     at java.lang.reflect.Method.invoke(Method.java:606) 
     at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:303) 
     at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:431) 
Caused by: java.lang.OutOfMemoryError: PermGen space 

我需要设置类路径吗?我以为我不需要设置任何.xml文件。

谢谢!

+2

** java.lang.OutOfMemoryError:PermGen space ** - 您需要为运行Tomcat的JVM分配更多内存。搜索这个错误,我相信你会找到答案 – 2014-12-04 13:29:29

回答

-1

此错误背后的原因之一是该端口已被分配给其他人。您可以通过更改端口地址来测试它。只需在资源目录下添加一个application.propeties。然后添加以下内容 server.port:9000 //您可以编写任何您想要的端口

相关问题