摘要:
在SpringBoot中,静态资源放在类路径下:resources/static or /public or /resources or /META-INT/resources 访问方法: 当前项目根路径(也就是/) + 静态资源名 (比如localhost:8080/timg.jpg) 如果在Co 阅读全文
posted @ 2021-11-11 17:13
Acc22222222
阅读(1003)
评论(0)
推荐(0)
摘要:
使用配置文件可以给类中的属性注入值。 配置文件(application.properties): mycar.brand = BYD mycar.price = 100000 控制器(controller):用于在网页上映射方法 @RestController //@RestContoller由 @ 阅读全文
posted @ 2021-11-11 15:02
Acc22222222
阅读(352)
评论(0)
推荐(0)
摘要:
配置类里使用@Bean标注在方法上给容器注册组件,默认是单实例的,称为Full模式,也就是说,返回的组件永远相同。 @SpringBootApplication public class MainApplication { public static void main(String[] args) 阅读全文
posted @ 2021-11-11 14:00
Acc22222222
阅读(901)
评论(0)
推荐(0)
摘要:
替代beans.xml 在Spring中,如果想要配置组件,需要用到 beans.xml,就像下面一样: ... <bean id = "user01" class = "com.example.bean.User"> //一个组件 <property name = "name" value = " 阅读全文
posted @ 2021-11-11 13:53
Acc22222222
阅读(381)
评论(0)
推荐(0)

浙公网安备 33010602011771号