原文链接:https://www.cnblogs.com/cndarren/p/11769342.html
demo实现的过程中也经历了很多的bug。bug开路!!!!
BUG1 :
这个是注解错误,复制的依赖都有错误。。。
在网上搜索得到的反馈是下载依赖缺失。
解决思路:
ok,解决
然后 第二个bug
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/F:/tool/idea/ij/IntelliJ%20IDEA%202017.2.2/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/E:/apache-maven-3.6.1-bin/apache-maven-3.6.1/conf/responsitory/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
大体的意思就是,有两个slf4j这个依赖,有冲突了。
解决方式,依赖有问题,需要排除这个logging
原文链接:https://blog.csdn.net/a704397849/article/details/98487404
第三个bug:
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Exception in thread "main" 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.loader.MainMethodRunner.run(MainMethodRunner.java:48)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:58)
Caused by: java.lang.IllegalArgumentException: LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. Either remove Logback or the competing implementation (class org.apache.logging.slf4j.Log4jLoggerFactory loaded from jar:file:/home/CubeStorageSystem-0.1-SNAPSHOT.jar!/BOOT-INF/lib/log4j-slf4j-impl-2.7.jar!/). If you are using WebLogic you will need to add 'org.slf4j' to prefer-application-packages in WEB-INF/weblogic.xml: org.apache.logging.slf4j.Log4jLoggerFactory
at org.springframework.util.Assert.instanceCheckFailed(Assert.java:389)
at org.springframework.util.Assert.isInstanceOf(Assert.java:327)
at org.springframework.boot.logging.logback.LogbackLoggingSystem.getLoggerContext(LogbackLoggingSystem.java:274)
at org.springframework.boot.logging.logback.Logb
问题原因,还是依赖的原因,因为依赖版本的原因导致出现错误
<dependency>
<groupId>org.apache.logging.log
4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.9.1</version>
</dependency>
原文链接:https://blog.csdn.net/Lovincc/article/details/78438291
到这里, 程序就算是跑起来了
展示结果:
1、 商品列表
http://localhost:8080/goods/to_list
response
success
[
{
"goods.goodsName":"iphone11",
"goods.goodsImg":"pic/iphone.png",
"goods.goodsPrice":"10000.0",
"goods.goodsmiaoshaPrice":"1.0",
"goods.stockCount":10,
"goods.id":3
}
{
"goods.goodsName":"p40",
"goods.goodsImg":"pic/p40.png",
"goods.goodsPrice":"6900.0",
"goods.goodsmiaoshaPrice":"1.0",
"goods.stockCount":10,
"goods.id":4
}
]
2、 商品详情页面
http://localhost:8080/goods/to_detail/3
response
success
[
{
"goods.goodsName":"iphone11",
"goods.goodsImg":"pic/iphone.png",
"goods.goodsPrice":"10000.0",
"goods.startDate":"2020-06-01 16:50:00",
"goods.miaoshaPrice":"1.0",
"goods.stockCount":10,
"goods.id":3
}
]