gpt4 book ai didi

Spring Boot - 应用程序无法使用类路径启动

转载 作者:行者123 更新时间:2023-11-28 22:34:03 26 4
gpt4 key购买 nike

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

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

Tomcat 版本 7,小服务程序 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 文件。

谢谢!

最佳答案

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

关于Spring Boot - 应用程序无法使用类路径启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27294671/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com