简体   繁体   English

无法执行目标 org.springframework.boot:spring-boot-maven-plugin:2.1.12.RELEASE:run (default-cli)

[英]Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.1.12.RELEASE:run (default-cli)

... "on project Jwplusapp: An exception occurred while running. null" ...“在项目 Jwplusapp 上:运行时发生异常。空”

Does anyone know why I cannot select "spring-boot:run" through maven without getting that error?有谁知道为什么我无法通过 Maven 选择“spring-boot:run”而不会出现该错误? Ive tried renaming the database file also making sure parent versions were correct.我试过重命名数据库文件也确保父版本是正确的。 i tried to check the pom.xml but i think i am just missing it.我试图检查 pom.xml 但我想我只是想念它。 any help in regards to this error code would be greatly appreciated.任何有关此错误代码的帮助将不胜感激。 yes i saw similar posts but they didnt seem to fix the problem for me.是的,我看到了类似的帖子,但他们似乎没有为我解决问题。

POM XML POM XML

<?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.1.12.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.test</groupId>
    <artifactId>Jwplusapp</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>
    <name>Jwplusapp</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>

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

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </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>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
        </dependency>

        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-jasper</artifactId>
            <scope>provided</scope>
        </dependency>

    </dependencies>

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

</project>

application.Properties应用程序.属性

spring.jpa.hibernate.ddl-auto=update
spring.datasource.url=jdbc:mysql://localhost:3306/Jwplus
spring.datasource.username=root
spring.datasource.password=root

ApplicationConfig.java应用程序配置文件

package com.test.Jwplusapp;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
import org.springframework.web.servlet.view.JstlView;

@Configuration
@ComponentScan(basePackages = "com.test.Jwplusapp")
public class ApplicationConfig extends WebMvcConfigurationSupport {

    @Override
    protected void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("css/**", "images/**")
                .addResourceLocations("classpath:/static/css/", "classpath:/static/images/");
    }

    @Bean
    public InternalResourceViewResolver jspViewResolver(){
        InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
        viewResolver.setPrefix("/WEB-INF/jsp/");
        viewResolver.setSuffix(".jsp");
        viewResolver.setViewClass(JstlView.class);
        return viewResolver;
    }
}

I tried with your pom.xml and it worked for me.我试过你的 pom.xml,它对我有用。 It fails with same error only when you have same port (8080 or whatever you are using in the application) has already been occupied.仅当您有相同的端口(8080 或您在应用程序中使用的任何端口)已被占用时,它才会失败并显示相同的错误。

Can you please check the availability of the port on which you are trying to run.(if its occupied try running on other port or kill the same).您能否检查您尝试运行的端口的可用性。(如果它被占用,请尝试在其他端口上运行或杀死相同的端口)。

Also can you please paste the complete error after "null" in the stacktrace.您也可以请在堆栈跟踪中的“null”之后粘贴完整的错误。

Updated:更新:

make sure you have following properties in your project确保您的项目中有以下属性

spring.jpa.hibernate.ddl-auto=update
spring.datasource.url=jdbc:mysql://${MYSQL_HOST:localhost}:3306/db_examplele
spring.datasource.username=springuser
spring.datasource.password=ThePassword

And try below configuration if you are using jpa如果您使用的是 jpa,请尝试以下配置

@Configuration        
public class HibernateConfig {

@Bean
public HibernateJpaSessionFactoryBean sessionFactory(EntityManagerFactory emf) {
     HibernateJpaSessionFactoryBean factory = new HibernateJpaSessionFactoryBean();
     factory.setEntityManagerFactory(emf);
     return factory;

}
}

Turns out the solution was not because of an error in my code but the solution was to Download MySQL Installer - MySQL原来解决方案不是因为我的代码中的错误,而是解决方案是下载 MySQL 安装程序 - MySQL

Here is the link to download这是下载链接

https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=2ahUKEwjEh8aMnbbnAhXKjVkKHSbQCSoQFjAAegQICxAC&url=https%3A%2F%2Fdev.mysql.com%2Fdownloads%2Finstaller%2F&usg=AOvVaw2HevAKGob4r4A7Rv_R2hy5 https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=2ahUKEwjEh8aMnbbnAhXKjVkKHSbQCSoQFjAAegQICxAC&url=https%3A%2F%2Fdev.mysql.com%2Fdownloads%2Finstaller%2F&usg= AOvVaw2HevAKGob4r4A7Rv_R2hy5

I figured this out when checking my services and noticing that MYSQL80 service was not displayed.(Checked Services, also Task manager -> Services)我在检查我的服务时发现了这一点,并注意到没有显示 MYSQL80 服务。(检查服务,还有任务管理器 -> 服务)

This then installed MySQL80 Service which was missing from my device, This then allowed my "spring-boot:run" to process successfully and open up my fully functioning webpage while connected to the desired localhost 3306 and fully connect to root on MYSQL workbench.然后安装了我的设备中缺少的 MySQL80 服务,然后这允许我的“spring-boot:run”成功处理并打开我功能齐全的网页,同时连接到所需的本地主机 3306 并完全连接到 MYSQL 工作台上的 root。

暂无
暂无

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

相关问题 未能执行目标 org.springframework.boot:spring-boot-maven-plugin:2.2.5.RELEASE:run (default-cli) - Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.2.5.RELEASE:run (default-cli) 无法执行目标 org.springframework.boot:spring-boot-maven-plugin:2.5.5:run (default-cli) - Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.5.5:run (default-cli) 无法在项目用户上执行目标 org.springframework.boot:spring-boot-maven-plugin:2.6.7:run (default-cli): - Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.6.7:run (default-cli) on project userms: 无法在项目 someProject 上执行目标 org.springframework.boot:spring-boot-maven-plugin:1.4.2.RELEASE:run (default-cli):无法执行 java - Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.4.2.RELEASE:run (default-cli) on project someProject: Could not exec java 无法执行目标org.springframework.boot:spring-boot-maven-plugin:1.5.8.RELEASE:run - Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.5.8.RELEASE:run 无法执行目标 org.springframework.boot:spring-boot-maven-plugin:2.2.2.RELEASE:run - Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.2.2.RELEASE:run 构建 docker 镜像时出错,无法在项目上执行目标 org.springframework.boot:spring-boot-maven-plugin:2.5.2:build-image (default-cli) - Error while building docker image, Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.5.2:build-image (default-cli) on project 无法执行目标 org.springframework.boot:spring-boot-maven-plugin:2.1.0.RELEASE - Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.1.0.RELEASE 无法执行目标 org.springframework.boot:spring-boot-maven-plugin:1.5.6.RELEASE - Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.5.6.RELEASE Maven - 无法执行目标 org.springframework.boot:spring-boot-maven-plugin:2.4.1:run - Maven - Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.4.1:run
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM