开发者社区> 问答> 正文

启动SpringBoot报错?报错

 

刚开始学习Spring-boot 

按照网路视频上进行的配置

这是我的pom文件,只有三处引用

1、parent标签            spring-boot-starter-parent

2、dependency标签  spring-context

3、dependency标签 spring-boot-starter

<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.edu</groupId>
    <artifactId>spring2</artifactId>
    <version>1.0.0</version>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.6.RELEASE</version>
    </parent>
    <name>springboot</name>
    <url>http://maven.apache.org</url>
    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>4.3.4.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
            <version>1.5.6.RELEASE</version>
        </dependency>
    </dependencies>
</project>

但是只有如下的包被依赖到了

parent标签没有接收到任何依赖,parent引入的是一个pom.xml文件

这是我的程序入口

@SpringBootApplication
public class App {
    public static void main(String[] args){
        ConfigurableApplicationContext context = SpringApplication.run(App.class, args);
        User user = context.getBean("user", User.class);
        user.show();
    }
    @Bean("user")
    public User createUser(){
        return new User();
    }
}

一执行就会包找不到Spring-expression的问题

java.lang.NoClassDefFoundError: org/springframework/expression/ParserContext
    at org.springframework.context.support.AbstractApplicationContext.prepareBeanFactory(AbstractApplicationContext.java:629) ~[spring-context-4.3.4.RELEASE.jar:4.3.4.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:517) ~[spring-context-4.3.4.RELEASE.jar:4.3.4.RELEASE]
    at org.springframework.boot.context.embedd

分析应该是parent的标签没有起作

搞了好长时间没有搞好,有时间的兄弟,帮忙给看看吧

 

 

 

 

展开
收起
爱吃鱼的程序员 2020-06-08 11:02:33 537 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    不需要springcontext的依赖


    springboot主函数在src/main/java根目录下时,会默认扫描所有的包,提示程序不希望这么做,加上@ComponentScan("zxw")限制一下扫描包就可以了 

    <divclass='ref'>

    引用来自“冷冷gg”的评论

    不需要springcontext的依赖应该是冲突去掉手动引入的context我试了一下可以

    2020-06-08 11:02:45
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
云栖社区特邀专家徐雷Java Spring Boot开发实战系列课程(第20讲):经典面试题与阿里等名企内部招聘求职面试技巧 立即下载
微服务架构模式与原理Spring Cloud开发实战 立即下载
阿里特邀专家徐雷Java Spring Boot开发实战系列课程(第18讲):制作Java Docker镜像与推送到DockerHub和阿里云Docker仓库 立即下载

相关实验场景

更多