spring-boot:run启动报错记录

博客记录了spring-boot:run启动失败的情况,给出了详细的启动日志和错误堆栈信息。经分析,问题原因是版本兼容问题,使用的springboot版本为2.0.3,而spring版本是4.3.13。

spring-boot:run启动失败

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building ycpd-vouchersystem-server 1.0.0
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] >>> spring-boot-maven-plugin:2.0.3.RELEASE:run (default-cli) > test-compile @ ycpd-vouchersystem-server >>>
[INFO] 
[INFO] --- maven-resources-plugin:2.7:resources (default-resources) @ ycpd-vouchersystem-server ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO] Copying 2 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.6.2:compile (default-compile) @ ycpd-vouchersystem-server ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:2.7:testResources (default-testResources) @ ycpd-vouchersystem-server ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\sxy\YCPD_JAVA\trunk\ycpd-parent\ycpd-vouchersystem\ycpd-vouchersystem-server\src\test\resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.6.2:testCompile (default-testCompile) @ ycpd-vouchersystem-server ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] <<< spring-boot-maven-plugin:2.0.3.RELEASE:run (default-cli) < test-compile @ ycpd-vouchersystem-server <<<
[INFO] 
[INFO] --- spring-boot-maven-plugin:2.0.3.RELEASE:run (default-cli) @ ycpd-vouchersystem-server ---
20:37:51.754 [background-preinit] DEBUG org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator - Loaded expression factory via original TCCL
20:37:51.764 [background-preinit] DEBUG org.hibernate.validator.internal.engine.ValidatorFactoryImpl - HV000234: Using org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator as ValidatorFactory-scoped message interpolator.
20:37:51.764 [background-preinit] DEBUG org.hibernate.validator.internal.engine.ValidatorFactoryImpl - HV000234: Using org.hibernate.validator.internal.engine.resolver.JPATraversableResolver as ValidatorFactory-scoped traversable resolver.
20:37:51.764 [background-preinit] DEBUG org.hibernate.validator.internal.engine.ValidatorFactoryImpl - HV000234: Using org.hibernate.validator.internal.util.ExecutableParameterNameProvider as ValidatorFactory-scoped parameter name provider.
20:37:51.764 [background-preinit] DEBUG org.hibernate.validator.internal.engine.ValidatorFactoryImpl - HV000234: Using org.hibernate.validator.internal.engine.DefaultClockProvider as ValidatorFactory-scoped clock provider.
20:37:51.764 [background-preinit] DEBUG org.hibernate.validator.internal.engine.ValidatorFactoryImpl - HV000234: Using org.hibernate.validator.internal.engine.scripting.DefaultScriptEvaluatorFactory as ValidatorFactory-scoped script evaluator factory.
[WARNING] 
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.boot.maven.AbstractRunMojo$LaunchRunner.run(AbstractRunMojo.java:496)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NoSuchMethodError: org.springframework.util.Assert.isTrue(ZLjava/util/function/Supplier;)V
    at org.springframework.boot.context.properties.source.ConfigurationPropertyName.lambda$append$2(ConfigurationPropertyName.java:185)
    at org.springframework.boot.context.properties.source.ConfigurationPropertyName.processElement(ConfigurationPropertyName.java:548)
    at org.springframework.boot.context.properties.source.ConfigurationPropertyName.process(ConfigurationPropertyName.java:524)
    at org.springframework.boot.context.properties.source.ConfigurationPropertyName.append(ConfigurationPropertyName.java:185)
    at org.springframework.boot.context.properties.bind.IndexedElementsBinder.bindIndexed(IndexedElementsBinder.java:112)
    at org.springframework.boot.context.properties.bind.IndexedElementsBinder.bindIndexed(IndexedElementsBinder.java:89)
    at org.springframework.boot.context.properties.bind.IndexedElementsBinder.bindIndexed(IndexedElementsBinder.java:71)
    at org.springframework.boot.context.properties.bind.ArrayBinder.bindAggregate(ArrayBinder.java:46)
    at org.springframework.boot.context.properties.bind.AggregateBinder.bind(AggregateBinder.java:58)
    at org.springframework.boot.context.properties.bind.Binder.lambda$bindAggregate$2(Binder.java:305)
    at org.springframework.boot.context.properties.bind.Binder$Context.withIncreasedDepth(Binder.java:441)
    at org.springframework.boot.context.properties.bind.Binder$Context.access$100(Binder.java:381)
    at org.springframework.boot.context.properties.bind.Binder.bindAggregate(Binder.java:304)
    at org.springframework.boot.context.properties.bind.Binder.bindObject(Binder.java:262)
    at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:221)
    at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:210)
    at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:166)
    at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.lambda$asDocuments$10(ConfigFileApplicationListener.java:572)
    at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
    at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382)
    at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
    at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
    at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
    at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.asDocuments(ConfigFileApplicationListener.java:576)
    at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.loadDocuments(ConfigFileApplicationListener.java:557)
    at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:518)
    at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.loadForFileExtension(ConfigFileApplicationListener.java:497)
    at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:465)
    at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.lambda$null$6(ConfigFileApplicationListener.java:447)
    at java.lang.Iterable.forEach(Iterable.java:75)
    at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.lambda$load$7(ConfigFileApplicationListener.java:446)
    at java.lang.Iterable.forEach(Iterable.java:75)
    at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:443)
    at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:335)
    at org.springframework.boot.context.config.ConfigFileApplicationListener.addPropertySources(ConfigFileApplicationListener.java:214)
    at org.springframework.boot.context.config.ConfigFileApplicationListener.postProcessEnvironment(ConfigFileApplicationListener.java:197)
    at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEnvironmentPreparedEvent(ConfigFileApplicationListener.java:184)
    at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEvent(ConfigFileApplicationListener.java:170)
    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.environmentPrepared(EventPublishingRunListener.java:74)
    at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54)
    at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:358)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:317)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1255)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1243)
    at org.ycpd.vouchersystem.server.VoucherSystemApplication.main(VoucherSystemApplication.java:10)
    ... 6 more
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.587 s
[INFO] Finished at: 2018-08-26T20:37:52+08:00
[INFO] Final Memory: 34M/276M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.0.3.RELEASE:run (default-cli) on project ycpd-vouchersystem-server: An exception occurred while running. null: InvocationTargetException: org.springframework.util.Assert.isTrue(ZLjava/util/function/Supplier;)V -> [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

问题原因:版本兼容问题,我的springboot2.0.3,而spring用的还是4.3.13

Spring boot 版本Spring Frameworkjdk 版本maven 版本
1.2.0 版本之前 63.0
1.2.04.1.3+63.2+
1.2.14.1.3+73.2+
1.2.34.1.5+73.2+
1.3.44.2.6+73.2+
1.3.64.2.7+73.2+
1.3.74.2.7+73.2+
1.3.84.2.8+73.2+
1.4.04.3.2+73.2+
1.4.14.3.373.2+
1.4.24.3.473.2+
1.4.34.3.573.2+
1.4.44.3.673.2+
1.4.54.3.773.2+
1.4.64.3.873.2+
1.4.74.3.973.2+
1.5.04.3.673.2+
1.5.24.3.773.2+
1.5.34.3.873.2+
1.5.44.3.973.2+
1.5.54.3.1073.2+
1.5.74.3.1173.2+
1.5.84.3.1273.2+
1.5.94.3.1373.2+
2.0.05.0.283.2+
你遇到的问题是: > **Plugin 'org.springframework.boot:spring-boot-maven-plugin:' not found** 但你在 `External Libraries` 中能看到 Spring Boot 的依赖(如 `spring-boot-starter-security` 等),这说明: ✅ 项目依赖已经成功下载 ❌ 但是 **Maven 插件没有找到**,所以无法打包、运行项目(比如执行 `mvn spring-boot:run` 或点击启动按钮会失败) --- ### 🔍 问题本质:插件 ≠ 普通依赖 虽然你看到了 `spring-boot-starter-*` 这些库被加载了,但它们是 **普通依赖(dependencies)**,而 `spring-boot-maven-plugin` 是一个 **Maven 构建插件(plugin)**。 两者存储位置不同、用途也不同: - `dependencies`:用于编译和运行代码 - `plugins`:用于构建过程本身(打包、启动、生成文档等) 即使你的项目能编译通过,如果插件没装好,就**不能用 Maven 命令来运行或打包 Spring Boot 应用**。 --- ## ✅ 正确解决方案(分步排查) ### ✅ 第一步:确认是否继承了 `spring-boot-starter-parent` 这是最关键的一步! 在你的 `pom.xml` 文件中,必须有以下内容: ```xml <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.7.12</version> <!-- 推荐使用稳定版本 --> <relativePath/> <!-- 不从本地查找父 POM --> </parent> ``` 📌 如果你没有这个 `<parent>` 标签,那么 Spring Boot 就不会自动帮你管理插件版本,即使写了 `<plugin>` 也可能找不到。 --- ### ✅ 第二步:检查 `<build><plugins>` 配置是否正确 确保你的 `pom.xml` 包含如下配置: ```xml <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <!-- 注意:这里不需要写 version!由 parent 管理 --> </plugin> </plugins> </build> ``` ⚠️ 千万不要这样写(空 version): ```xml <version></version> <!-- 错误!会导致 not found --> ``` 也不要漏掉标签。 --- ### ✅ 第三步:如果你没用 parent → 必须手动 import 并指定版本 如果你因为多模块项目或其他原因不能使用 `<parent>`,那就要用 `dependencyManagement` + 显式声明插件版本。 #### 替代方案(推荐用于复杂项目结构): ```xml <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-dependencies</artifactId> <version>2.7.12</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>2.7.12</version> <!-- 必须显式指定! --> </plugin> </plugins> </build> ``` --- ### ✅ 第四步:清理缓存并强制重新加载 有时候 `.m2` 仓库中的插件元数据损坏,导致 Maven 找不到插件。 #### 操作步骤: 1. 关闭 IDEA 2. 删除本地仓库中与 Spring Boot 相关的目录: ```bash rm -rf ~/.m2/repository/org/springframework/boot/spring-boot-maven-plugin rm -rf ~/.m2/repository/org/springframework/boot/spring-boot-starter-parent ``` 3. 重新打开项目 4. 在 IDEA 中右键点击 `pom.xml` → **Maven → Reload Project** 或者终端执行: ```bash mvn clean compile -U ``` 其中 `-U` 强制更新所有快照和插件。 --- ### ✅ 第五步:配置阿里云镜像(解决国内网络问题) 很多情况下,“not found” 其实是因为 **下载失败但不报错明显信息**。 编辑 `~/.m2/settings.xml`,添加阿里云镜像: ```xml <?xml version="1.0" encoding="UTF-8"?> <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> <mirrors> <mirror> <id>aliyunmaven</id> <mirrorOf>*</mirrorOf> <name>阿里云公共仓库</name> <url>https://maven.aliyun.com/repository/public</url> </mirror> </mirrors> <profiles> <profile> <id>jdk-1.8</id> <activation> <activeByDefault>true</activeByDefault> <jdk>1.8</jdk> </activation> <properties> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> <maven.compiler.release>1.8</maven.compiler.release> </properties> </profile> </profiles> </settings> ``` 保存后重启 IDEA,再 reload。 --- ### ✅ 第六步:验证插件是否已识别 Reload 完成后,查看右侧 **Maven 工具窗口**: 展开: ``` Plugins └─ spring-boot └─ spring-boot:build-info └─ spring-boot:repackage └─ spring-boot:start └─ spring-boot:stop ``` 如果有这些目标出现 → 插件已成功加载 ✅ 你现在可以安全地运行: ```bash mvn spring-boot:run ``` 或在 IDEA 中点击绿色三角 ▶️ 启动应用。 --- ### ❌ 常见错误对比表 | 错误现象 | 原因 | 解决方法 | |--------|------|---------| | Plugin not found | 缺少 parent 或未指定 version | 添加 parent 或显式写 version | | 能看到依赖但不能运行 | 插件未加载 | 检查 build/plugin 配置 | | Reload 后仍报错 | 缓存损坏 | 删除 `.m2` 对应文件夹 | | 下载极慢或超时 | 国内访问中央仓库慢 | 配置阿里云镜像 | --- ### ✅ 总结:你应该怎么做? 1. ✅ 确保 `pom.xml` 包含 `<parent>spring-boot-starter-parent</parent>` 2. ✅ 在 `<build>` 中正确声明 `spring-boot-maven-plugin`(无需 version) 3. ✅ 配置阿里云镜像加速下载 4. ✅ 删除 `.m2` 缓存中相关目录 5. ✅ 执行 `Reload Project` 或 `mvn -U compile` 完成以上步骤后,99% 的“Plugin not found”问题都能解决。 --- ###
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值