【问题标题】:Spring Boot - Application failed to start with classpathSpring Boot - 应用程序无法使用类路径启动
【发布时间】:2015-02-02 08:53:50
【问题描述】:

多么美好的一天,不是吗?

我希望这个社区的人可以帮助我。

Tomcat 版本 7, Servlet API 3.0

我喜欢使用 .war 在 tomcat 中启动我的 Spring Boot 项目。这是我的 Spring Boot 应用程序代码:

主类

@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

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

tomcat/spring boot的错误提示

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.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@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 文件。

谢谢!

【问题讨论】:

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

标签: spring tomcat war spring-boot


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2018-03-17
    • 2015-05-10
    • 2020-08-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-10
    相关资源
    最近更新 更多