eclipse正常 ,命令行mvn spring-boot:run 报错

安装java10 后,mvn spring-boot:run 报错

Exception in thread "main" java.lang.ClassCastException: 
    java.base/jdk.internal.loader.ClassLoaders$AppClassLoader 
    cannot be cast to java.base/java.net.URLClassLoader
        at org.springframework.boot.devtools.restart.DefaultRestartInitializer.getUrls(DefaultRestartInitializer.java:93)
        at org.springframework.boot.devtools.restart.DefaultRestartInitializer.getInitialUrls(DefaultRestartInitializer.java:56)




mvn spring-boot:run
[INFO] Scanning for projects...
......
[INFO] Attaching agents: []
Exception in thread "main" java.lang.ClassCastException: java.base/jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to java.base/java.net.URLClassLoader
        at org.springframework.boot.devtools.restart.DefaultRestartInitializer.getUrls(DefaultRestartInitializer.java:93)
        at org.springframework.boot.devtools.restart.DefaultRestartInitializer.getInitialUrls(DefaultRestartInitializer.java:56)
        at org.springframework.boot.devtools.restart.Restarter.<init>(Restarter.java:140)
        at org.springframework.boot.devtools.restart.Restarter.initialize(Restarter.java:583)
        at org.springframework.boot.devtools.restart.RestartApplicationListener.onApplicationStartingEvent(RestartApplicationListener.java:67)
        at org.springframework.boot.devtools.restart.RestartApplicationListener.onApplicationEvent(RestartApplicationListener.java:45)
        at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
        at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
        at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
        at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:122)
        at org.springframework.boot.context.event.EventPublishingRunListener.starting(EventPublishingRunListener.java:69)
        at org.springframework.boot.SpringApplicationRunListeners.starting(SpringApplicationRunListeners.java:48)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:292)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.803 s
[INFO] Finished at: 2018-05-23T21:30:02+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.5.12.RELEASE:run (default-cli) on project hgmonitor: Could not exec java: Application finished with exit code: 1 -> [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/MojoExecutionException
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Eclipse 中使用 Maven 启动 Spring Boot 有两种方式:通过 Maven 插件启动或者通过 Eclipse 插件启动。 1. 通过 Maven 插件启动: 步骤如下: 1. 在项目的 pom.xml 文件中添加 Spring Boot Maven 插件: ```xml <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> ``` 2. 在 Maven 的 Profiles 中添加 Spring Boot 启动配置: ```xml <profiles> <profile> <id>spring-boot</id> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <executions> <execution> <goals> <goal>run</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </profile> </profiles> ``` 3. 保存 pom.xml 文件并使用 Maven 命令启动 Spring Boot 应用程序: ```bash mvn spring-boot:run ``` 2. 通过 Eclipse 插件启动: 步骤如下: 1. 安装 Spring Tool Suite 插件。 2. 在项目的 pom.xml 文件中添加 Spring Boot Starter Parent 依赖。 3. 右键点击 pom.xml 文件,选择 Run As -> Maven build。 4. 在 Goals 中输入 `spring-boot:run`,然后点击 Run 按钮。 5. 等待应用程序启动完成后,使用浏览器访问 http://localhost:8080 即可访问应用程序。 注意:在使用 Eclipse 插件启动 Spring Boot 应用程序时,Eclipse 会自动检测项目中是否引入了 Spring Boot 相关依赖,如果没有则会提示你手动添加依赖。同时,Eclipse 也会自动配置应用程序的端口号和上下文路径等参数,无需手动配置。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值