刚开始学习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的标签没有起作
搞了好长时间没有搞好,有时间的兄弟,帮忙给看看吧
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。
不需要springcontext的依赖
springboot主函数在src/main/java根目录下时,会默认扫描所有的包,提示程序不希望这么做,加上@ComponentScan("zxw")限制一下扫描包就可以了