首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法运行非常干净的Spring Boot项目

无法运行非常干净的Spring Boot项目
EN

Stack Overflow用户
提问于 2020-04-30 00:42:52
回答 2查看 1.1K关注 0票数 1

我对Java技术非常陌生(通常在NodeJs和PHP上工作,但需要使用Spring Boot)。我只想在Spring MVC上运行'Hello World‘。但我已经花了一天了。我不知道为什么初始化一个项目会很难。

我从https://start.spring.io/构建了一个项目

代码语言:javascript
复制
Project: Marven, LanguageL Java, Spring Boot:2.2.6, Packing: Java, Java: 11
Dependencies: Spring Web WEB, Thymeleaf and Spring Boot DevTools. 

我的mvn -version

代码语言:javascript
复制
Maven home: /usr/local/Cellar/maven/3.6.0/libexec
Java version: 11.0.7, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk-11.0.7.jdk/Contents/Home
Default locale: en_TH, platform encoding: UTF-8
OS name: "mac os x", version: "10.14.5", arch: "x86_64", family: "mac"

我的pom.xml

代码语言:javascript
复制
<?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.2.6.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.myproject</groupId>
    <artifactId>front-end-server</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>front-end-server</name>
    <description>Front End Server</description>

    <properties>
        <java.version>11</java.version>
    </properties>

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

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>

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

</project>

当我尝试运行它时,总是返回错误,

代码语言:javascript
复制
[INFO] Total time:  0.604 s
[INFO] Finished at: 2020-04-29T23:22:55+07:00
[INFO] ------------------------------------------------------------------------
[WARNING] The requested profile "pom.xml" could not be activated because it does not exist.
[ERROR] Unknown lifecycle phase "mvn". You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/LifecyclePhaseNotFoundException

我也关注了http://cwiki.apache.org/confluence/display/MAVEN/LifecyclePhaseNotFoundException。但它不起作用。

我也尝试了https://crunchify.com/mavenmvn-clean-install-update-project-and-project-clean-options-in-eclipse-ide-to-fix-any-dependency-issue/的解决方案,它不再起作用了。

此外,我还使用Spring Tool Suite4创建了一个新项目(希望得到不同的结果)。它的效果不是很好。

我通常只需要不到30分钟的时间就能开始一个新事物的“你好世界”。但是对于Spring boot,它已经花了我一整天了。

请帮帮我..

EN

回答 2

Stack Overflow用户

发布于 2020-04-30 00:45:34

您运行的是什么命令?像"mvn干净安装“这样的东西应该可以工作。

票数 0
EN

Stack Overflow用户

发布于 2020-04-30 00:54:56

进入您的项目文件夹,并在终端中运行此命令。

mvn全新安装-DskipTests

之后,右击你的主程序,点击run as spring boot app。应该能行得通。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61507005

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档