简体   繁体   English

在 eclipse 中运行 spring 启动 maven 项目时面临问题,该项目在运行时被终止

[英]Facing issue while running spring boot maven project in eclipse which on running gets terminated

When I am trying to run the spring boot maven project using java application in console on top it shows but below it shows everything is started i even included tomcat so it will be able to load in the browser too but it is not loading in the browser and gets terminated I am not able to understand where is the issue currently so that i can run the application successfully Please check the POM file mentioned and the screen shot attached while running. I had even tried removing.m2 repository and perform clean build and rerun again then too no changes appeared. When I am trying to run the spring boot maven project using java application in console on top it shows but below it shows everything is started i even included tomcat so it will be able to load in the browser too but it is not loading in the browser并被终止我无法理解当前问题出在哪里,以便我可以成功运行应用程序Please check the POM file mentioned and the screen shot attached while running. I had even tried removing.m2 repository and perform clean build and rerun again then too no changes appeared. Please check the POM file mentioned and the screen shot attached while running. I had even tried removing.m2 repository and perform clean build and rerun again then too no changes appeared. I just wanted to launch the spring boot application in the browser so if there is any wrong in my code while running like spring-boot maven project i am right clicking on the main class and performing run as java application I have even added dependency for using restcontroller which i am getting a classpath error where after changing the class path to.m2 repository it is still not resolved I just wanted to launch the spring boot application in the browser so if there is any wrong in my code while running like spring-boot maven project i am right clicking on the main class and performing run as java application I have even added dependency for using restcontroller which我收到一个类路径错误,在将 class 路径更改为.m2 存储库后,它仍然没有解决

<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.5.0-SNAPSHOT</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>springproj</groupId>
    <artifactId>springapp</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>springapp</name>
    <description>Demo project for Spring Boot</description>
    <properties>
        <java.version>11</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
        
        <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>4.1.6.RELEASE</version>
    </dependency>
        
<dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
</dependency>


        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
        
        <resources>
        <resource>
            <directory>src/main/resources</directory>
            <filtering>true</filtering>
        </resource>
    </resources>
        
    </build>
    <repositories>
        <repository>
            <id>spring-milestones</id>
            <name>Spring Milestones</name>
            <url>https://repo.spring.io/milestone</url>
        </repository>
        <repository>
            <id>spring-snapshots</id>
            <name>Spring Snapshots</name>
            <url>https://repo.spring.io/snapshot</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>spring-milestones</id>
            <name>Spring Milestones</name>
            <url>https://repo.spring.io/milestone</url>
        </pluginRepository>
        <pluginRepository>
            <id>spring-snapshots</id>
            <name>Spring Snapshots</name>
            <url>https://repo.spring.io/snapshot</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>

</project>

Screen Shot of Console控制台屏幕截图

After adding dependency screenshot添加依赖后截图

You are using incompatible versions in your dependencies.您在依赖项中使用了不兼容的版本。 You should be using spring boot dependency management plugin to be on the safe side.为了安全起见,您应该使用 spring 引导依赖管理插件。 Replace代替

<dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>4.1.6.RELEASE</version>
    </dependency>

with spring boot starter webspring boot starter web

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM