准备
控制器代码包含Spring代码处多处错误
未更新pom.xml或者其中没有包含所需要的dependency
更新依赖项慢,更改镜像地址
右键pom.xml,选择Maven,选择打开settings.xml(若没有,选择新建)
<mirrors>
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
<mirror>
<id>uk</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://uk.maven.org/maven2/</url>
</mirror>
<mirror>
<id>CN</id>
<name>OSChina Central</name>
<url>http://maven.oschina.net/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
<mirror>
<id>nexus</id>
<name>internal nexus repository</name>
<!-- <url>http://192.168.1.100:8081/nexus/content/groups/public/</url>-->
<url>http://repo.maven.apache.org/maven2</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
webapp文件夹位置
第一个程序
index.jsp无法显示
将该界面的Facet配置好,根据实际情况自行配置
log4j:No appenders could be found for logger
resources文件夹下新建log4j.properties,并粘贴如下代码
log4j.rootLogger=DEBUG, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] - %m%n
Unsatisfied dependency expressed through field ‘类名’; nested exception is 。。。
忘记添加@Component
@ComponentScan(basePackages={“com.springboot.chapter3”},excludeFilters={@Filter(classes=Service.class)}),不添加排除项时不报错,添加后报错
改用下面的方式
@ComponentScan(value = "com.springboot.springbootlearning.chapter3.*",excludeFilters = {
//排除某些类
//排除Controller注解标注的类
//@ComponentScan.Filter(type = FilterType.ANNOTATION, classes = {Service.class}),
//排除指定类型的类
@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE,value ={com.springboot.springbootlearning.chapter3.service.UserService.class} )
})
无法找到Mapper类型的Bean
在@Mapper前面加上@Component(value=“UserMapperMybatisPlus”)