Giter VIP home page Giter VIP logo

springboot-learning's Issues

使用Swagger时出现MethodArgumentTypeMismatchException

当调用url中包含参数的restful接口时,会报错,原因是指定为Long类型的参数在请求时被识别为String,导致类型不匹配报错。

以获取用户详细信息接口为例:
在SwaggerUI上输入value为1,然后try it out,结果是:

{
  "timestamp": 1488971240704,
  "status": 400,
  "error": "Bad Request",
  "exception": "org.springframework.web.method.annotation.MethodArgumentTypeMismatchException",
  "message": "Failed to convert value of type [java.lang.String] to required type [java.lang.Long]; nested exception is java.lang.NumberFormatException: For input string: \"{id}\"",
  "path": "/users/%7Bid%7D"
}

Chapter1

根pom.xml
依赖

org.springframework.boot
spring-boot-starter-web

以后可以不需要再依赖

org.springframework.boot
spring-boot-starter

ch3-2-5中redis的配置错误

redis连接根本就没用application.properties中的吖

 JedisConnectionFactory jedisConnectionFactory() {
        return new JedisConnectionFactory();
    }
public JedisConnectionFactory() {
        this.hostName = "localhost";
        this.port = 6379;
        this.timeout = 2000;
        this.usePool = true;
        this.poolConfig = new JedisPoolConfig();
        this.dbIndex = 0;
        this.convertPipelineAndTxResults = true;
}

这根本就是默认配置嘛~

chapter1-1编译报错

Project build error: 'packaging' with value 'jar' is invalid. Aggregator projects require 'pom' as packaging.

Spring Boot 2.x基础教程:使用EhCache缓存集群 本地环境怎么部署?

本地环境 只更改端口 发现不生效

ehcache-1.xml

<cacheManagerPeerProviderFactory
            class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
            properties="hostName=localhost,
                        port=40001,
                        socketTimeoutMillis=2000,
                        peerDiscovery=manual,
                        rmiUrls=//localhost:40002/users" />

ehcache-2.xml

  <cacheManagerPeerProviderFactory
            class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
            properties="hostName=localhost,
                        port=40002,
                        socketTimeoutMillis=2000,
                        peerDiscovery=manual,
                        rmiUrls=//localhost:40001/users" />

chapter 2-1

idea测试出中文乱码问题。
java.lang.AssertionError: Response content
Expected: "[{"id":1,"name":"测试大师","age":20}]"
but: was "[{"id":1,"name":"???è???¤§???","age":20}]"
搜了半天,file encoding都改成utf-8了,但是还是乱码。

chapter3-3配置druid监控的问题

"第一步:在pom.xml中引入spring-boot-starter-actuator模块"关于这一步的问题

我使用的springboot版本是2.6.3,引入的swagger2启动报错:Failed to start bean ‘documentationPluginsBootstrapper’; nested exception is java.lang.NullPointerException,然后增加配置spring.mvc.pathmatch.matching-strategy=ant_path_matche解决上述启动报错的问题。

但是引入spring-boot-starter-actuator依赖,启动项目又出现上述问题。
好几天了,没找到怎么解决,( ̄﹏ ̄;)

springboot 2.x 应用部署到weblogic12

hi,我是用springboot 1.5 能成功部署web到weblogic12上且不需要配置web.xml文件,只需配置weblogic.xml文件;但是使用springboot 2.1.9 怎么都不能成功部署,请问能出一节讲解如何部署springboot 2.x 应用至weblogic12年文章吗?谢谢🙏

同时使用JPA与Swagger会报错

报错信息:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'documentationPluginsBootstrapper' defined in URL [jar:file:/D:/Software/Apache/apache-maven-3.6.0/repository/io/springfox/springfox-spring-web/2.9.2/springfox-spring-web-2.9.2.jar!/springfox/documentation/spring/web/plugins/DocumentationPluginsBootstrapper.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'webMvcRequestHandlerProvider' defined in URL [jar:file:/D:/Software/Apache/apache-maven-3.6.0/repository/io/springfox/springfox-spring-web/2.9.2/springfox-spring-web-2.9.2.jar!/springfox/documentation/spring/web/plugins/WebMvcRequestHandlerProvider.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Unsatisfied dependency expressed through method 'requestMappingHandlerMapping' parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mvcConversionService' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.format.support.FormattingConversionService]: Factory method 'mvcConversionService' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Validation failed for query for method public abstract top.aengus.demo.model.User top.aengus.demo.dao.interfaces.UserRepository.findUser(java.lang.String)!

hello world都起不了

第一个项目helloworld都起不来,
初学者!
Field error in object 'server' on field 'port': rejected value [8080;]; codes [typeMismatch.server.port,typeMismatch.port,typeMismatch.java.lang.Integer,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [server.port,port]; arguments []; default message [port]]; default message [Failed to convert property value of type [java.lang.String] to required type [java.lang.Integer] for property 'port'; nested exception is org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.lang.String] to type [java.lang.Integer]]
2018-07-27 15:30:38.459 ERROR 17384 --- [ main] o.s.boot.SpringApplication : Application startup failed
有人知道原因吗?
--谢谢各位大佬

Spring Boot中的缓存支持——EhCache使用 有问题

你好,我看你给的示例Chapter-4-4-1中,当删除一条记录后,仍然可以通过findByName获取被删除的数据,这个应该是有问题的吧,自带的 delete方法执行时候应该是没有清楚缓存吧;

多服务实例 启动冲突

spring.flyway.locations=classpath:db/migration

按照Demo样例 可以实现单服务 使用 FlyWay 方式管理数据库脚本,但是在多服务下 使用FlyWay异常。原因是因为 A服务启动后,数据库中已经存在 flyway_schema_history 表,而 B服务在启动的时候 ,直接报错。 org.flywaydb.core.api.exception.FlywayValidateException: Validate failed: Migrations have failed validation

elastic-job启动报错

SpringBoot-Learning/2.x/chapter7-2/启动报错,如下图。请求对zk版本有什么要求?
WX20211014-110205

chapter2-5 测试好像有问题

1.测试问题

@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)改为@SpringBootTest好像就可以了。
see https://github.com/dyc87112/SpringBoot-Learning/blob/master/2.1.x/chapter2-5/src/test/java/com/didispace/chapter25/DemoApplicationTests.java#L17

2.maven install问题

[ERROR] Tests run: 3, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 6.329 s <<< FAILURE! - in com.didispace.chapter25.DemoApplicationTests
[ERROR] generateAsciiDocs(com.didispace.chapter25.DemoApplicationTests)  Time elapsed: 0.736 s  <<< ERROR!
java.lang.NoClassDefFoundError: org/pegdown/PegDownProcessor
	at com.didispace.chapter25.DemoApplicationTests.generateAsciiDocs(DemoApplicationTests.java:35)
Caused by: java.lang.ClassNotFoundException: org.pegdown.PegDownProcessor
	at com.didispace.chapter25.DemoApplicationTests.generateAsciiDocs(DemoApplicationTests.java:35)

2020-08-01 11:35:18.228  INFO 9356 --- [       Thread-2] o.s.s.concurrent.ThreadPoolTaskExecutor  : Shutting down ExecutorService 'applicationTaskExecutor'
[INFO] 
[INFO] Results:
[INFO] 
[ERROR] Errors: 
[ERROR]   DemoApplicationTests.generateAsciiDocs:35 » NoClassDefFound org/pegdown/PegDow...
[INFO] 
[ERROR] Tests run: 3, Failures: 0, Errors: 1, Skipped: 0
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  16.299 s
[INFO] Finished at: 2020-08-01T11:35:18+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.1:test (default-test) on project chapter2-5: There are test failures.
[ERROR] 
[ERROR] Please refer to G:\Workspaces\MyEclipse2017\SpringBoot-Learning\2.1.x\chapter2-5\target\surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

chapter3-9,不知道为什么,事务回滚了

下面是控制台输出:

/Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home/bin/java -ea -Didea.test.cyclic.buffer.size=1048576 -javaagent:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar=49350:/Applications/IntelliJ IDEA.app/Contents/bin -Dfile.encoding=UTF-8 -classpath /Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/junit/lib/junit5-rt.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/junit/lib/junit-rt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home/jre/lib/charsets.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home/jre/lib/deploy.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home/jre/lib/ext/cldrdata.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home/jre/lib/ext/dnsns.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home/jre/lib/ext/jaccess.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home/jre/lib/ext/jfxrt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home/jre/lib/ext/localedata.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home/jre/lib/ext/nashorn.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home/jre/lib/ext/sunec.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home/jre/lib/ext/zipfs.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home/jre/lib/javaws.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home/jre/lib/jce.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home/jre/lib/jfr.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home/jre/lib/jfxswt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home/jre/lib/jsse.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home/jre/lib/management-agent.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home/jre/lib/plugin.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home/jre/lib/resources.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home/jre/lib/rt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home/lib/ant-javafx.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home/lib/dt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home/lib/javafx-mx.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home/lib/jconsole.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home/lib/packager.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home/lib/sa-jdi.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home/lib/tools.jar:/Users/mike/Desktop/Demos/multi_data_source/target/test-classes:/Users/mike/Desktop/Demos/multi_data_source/target/classes:/Users/mike/.m2/repository/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar:/Users/mike/.m2/repository/org/springframework/boot/spring-boot-starter-data-jdbc/2.1.3.RELEASE/spring-boot-starter-data-jdbc-2.1.3.RELEASE.jar:/Users/mike/.m2/repository/org/springframework/boot/spring-boot-starter-jdbc/2.1.3.RELEASE/spring-boot-starter-jdbc-2.1.3.RELEASE.jar:/Users/mike/.m2/repository/com/zaxxer/HikariCP/3.2.0/HikariCP-3.2.0.jar:/Users/mike/.m2/repository/org/springframework/spring-jdbc/5.1.5.RELEASE/spring-jdbc-5.1.5.RELEASE.jar:/Users/mike/.m2/repository/org/springframework/data/spring-data-jdbc/1.0.5.RELEASE/spring-data-jdbc-1.0.5.RELEASE.jar:/Users/mike/.m2/repository/org/springframework/data/spring-data-commons/2.1.5.RELEASE/spring-data-commons-2.1.5.RELEASE.jar:/Users/mike/.m2/repository/org/springframework/spring-tx/5.1.5.RELEASE/spring-tx-5.1.5.RELEASE.jar:/Users/mike/.m2/repository/org/springframework/spring-context/5.1.5.RELEASE/spring-context-5.1.5.RELEASE.jar:/Users/mike/.m2/repository/org/springframework/spring-beans/5.1.5.RELEASE/spring-beans-5.1.5.RELEASE.jar:/Users/mike/.m2/repository/org/slf4j/slf4j-api/1.7.25/slf4j-api-1.7.25.jar:/Users/mike/.m2/repository/org/springframework/boot/spring-boot-starter-web/2.1.3.RELEASE/spring-boot-starter-web-2.1.3.RELEASE.jar:/Users/mike/.m2/repository/org/springframework/boot/spring-boot-starter/2.1.3.RELEASE/spring-boot-starter-2.1.3.RELEASE.jar:/Users/mike/.m2/repository/org/springframework/boot/spring-boot/2.1.3.RELEASE/spring-boot-2.1.3.RELEASE.jar:/Users/mike/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/2.1.3.RELEASE/spring-boot-autoconfigure-2.1.3.RELEASE.jar:/Users/mike/.m2/repository/org/springframework/boot/spring-boot-starter-logging/2.1.3.RELEASE/spring-boot-starter-logging-2.1.3.RELEASE.jar:/Users/mike/.m2/repository/ch/qos/logback/logback-core/1.2.3/logback-core-1.2.3.jar:/Users/mike/.m2/repository/org/apache/logging/log4j/log4j-to-slf4j/2.11.2/log4j-to-slf4j-2.11.2.jar:/Users/mike/.m2/repository/org/apache/logging/log4j/log4j-api/2.11.2/log4j-api-2.11.2.jar:/Users/mike/.m2/repository/org/slf4j/jul-to-slf4j/1.7.25/jul-to-slf4j-1.7.25.jar:/Users/mike/.m2/repository/javax/annotation/javax.annotation-api/1.3.2/javax.annotation-api-1.3.2.jar:/Users/mike/.m2/repository/org/yaml/snakeyaml/1.23/snakeyaml-1.23.jar:/Users/mike/.m2/repository/org/springframework/boot/spring-boot-starter-json/2.1.3.RELEASE/spring-boot-starter-json-2.1.3.RELEASE.jar:/Users/mike/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.9.8/jackson-databind-2.9.8.jar:/Users/mike/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.9.0/jackson-annotations-2.9.0.jar:/Users/mike/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.9.8/jackson-core-2.9.8.jar:/Users/mike/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-jdk8/2.9.8/jackson-datatype-jdk8-2.9.8.jar:/Users/mike/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-jsr310/2.9.8/jackson-datatype-jsr310-2.9.8.jar:/Users/mike/.m2/repository/com/fasterxml/jackson/module/jackson-module-parameter-names/2.9.8/jackson-module-parameter-names-2.9.8.jar:/Users/mike/.m2/repository/org/springframework/boot/spring-boot-starter-tomcat/2.1.3.RELEASE/spring-boot-starter-tomcat-2.1.3.RELEASE.jar:/Users/mike/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/9.0.16/tomcat-embed-core-9.0.16.jar:/Users/mike/.m2/repository/org/apache/tomcat/embed/tomcat-embed-el/9.0.16/tomcat-embed-el-9.0.16.jar:/Users/mike/.m2/repository/org/apache/tomcat/embed/tomcat-embed-websocket/9.0.16/tomcat-embed-websocket-9.0.16.jar:/Users/mike/.m2/repository/org/hibernate/validator/hibernate-validator/6.0.14.Final/hibernate-validator-6.0.14.Final.jar:/Users/mike/.m2/repository/javax/validation/validation-api/2.0.1.Final/validation-api-2.0.1.Final.jar:/Users/mike/.m2/repository/org/jboss/logging/jboss-logging/3.3.2.Final/jboss-logging-3.3.2.Final.jar:/Users/mike/.m2/repository/com/fasterxml/classmate/1.4.0/classmate-1.4.0.jar:/Users/mike/.m2/repository/org/springframework/spring-web/5.1.5.RELEASE/spring-web-5.1.5.RELEASE.jar:/Users/mike/.m2/repository/org/springframework/spring-webmvc/5.1.5.RELEASE/spring-webmvc-5.1.5.RELEASE.jar:/Users/mike/.m2/repository/org/springframework/spring-aop/5.1.5.RELEASE/spring-aop-5.1.5.RELEASE.jar:/Users/mike/.m2/repository/org/springframework/spring-expression/5.1.5.RELEASE/spring-expression-5.1.5.RELEASE.jar:/Users/mike/.m2/repository/org/springframework/boot/spring-boot-starter-test/2.1.3.RELEASE/spring-boot-starter-test-2.1.3.RELEASE.jar:/Users/mike/.m2/repository/org/springframework/boot/spring-boot-test/2.1.3.RELEASE/spring-boot-test-2.1.3.RELEASE.jar:/Users/mike/.m2/repository/org/springframework/boot/spring-boot-test-autoconfigure/2.1.3.RELEASE/spring-boot-test-autoconfigure-2.1.3.RELEASE.jar:/Users/mike/.m2/repository/com/jayway/jsonpath/json-path/2.4.0/json-path-2.4.0.jar:/Users/mike/.m2/repository/net/minidev/json-smart/2.3/json-smart-2.3.jar:/Users/mike/.m2/repository/net/minidev/accessors-smart/1.2/accessors-smart-1.2.jar:/Users/mike/.m2/repository/org/ow2/asm/asm/5.0.4/asm-5.0.4.jar:/Users/mike/.m2/repository/org/assertj/assertj-core/3.11.1/assertj-core-3.11.1.jar:/Users/mike/.m2/repository/org/mockito/mockito-core/2.23.4/mockito-core-2.23.4.jar:/Users/mike/.m2/repository/net/bytebuddy/byte-buddy/1.9.10/byte-buddy-1.9.10.jar:/Users/mike/.m2/repository/net/bytebuddy/byte-buddy-agent/1.9.10/byte-buddy-agent-1.9.10.jar:/Users/mike/.m2/repository/org/objenesis/objenesis/2.6/objenesis-2.6.jar:/Users/mike/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar:/Users/mike/.m2/repository/org/hamcrest/hamcrest-library/1.3/hamcrest-library-1.3.jar:/Users/mike/.m2/repository/org/skyscreamer/jsonassert/1.5.0/jsonassert-1.5.0.jar:/Users/mike/.m2/repository/com/vaadin/external/google/android-json/0.0.20131108.vaadin1/android-json-0.0.20131108.vaadin1.jar:/Users/mike/.m2/repository/org/springframework/spring-core/5.1.5.RELEASE/spring-core-5.1.5.RELEASE.jar:/Users/mike/.m2/repository/org/springframework/spring-jcl/5.1.5.RELEASE/spring-jcl-5.1.5.RELEASE.jar:/Users/mike/.m2/repository/org/springframework/spring-test/5.1.5.RELEASE/spring-test-5.1.5.RELEASE.jar:/Users/mike/.m2/repository/org/xmlunit/xmlunit-core/2.6.2/xmlunit-core-2.6.2.jar:/Users/mike/.m2/repository/javax/xml/bind/jaxb-api/2.3.1/jaxb-api-2.3.1.jar:/Users/mike/.m2/repository/javax/activation/javax.activation-api/1.2.0/javax.activation-api-1.2.0.jar:/Users/mike/.m2/repository/org/mybatis/spring/boot/mybatis-spring-boot-starter/2.1.3/mybatis-spring-boot-starter-2.1.3.jar:/Users/mike/.m2/repository/org/mybatis/spring/boot/mybatis-spring-boot-autoconfigure/2.1.3/mybatis-spring-boot-autoconfigure-2.1.3.jar:/Users/mike/.m2/repository/org/mybatis/mybatis/3.5.5/mybatis-3.5.5.jar:/Users/mike/.m2/repository/org/mybatis/mybatis-spring/2.0.5/mybatis-spring-2.0.5.jar:/Users/mike/.m2/repository/mysql/mysql-connector-java/8.0.15/mysql-connector-java-8.0.15.jar:/Users/mike/.m2/repository/org/projectlombok/lombok/1.18.6/lombok-1.18.6.jar:/Users/mike/.m2/repository/junit/junit/4.13/junit-4.13.jar com.intellij.rt.junit.JUnitStarter -ideVersion5 -junit4 com.example.multi_data_source.MultiDataSourceApplicationTests,test
10:35:42.154 [main] DEBUG org.springframework.test.context.junit4.SpringJUnit4ClassRunner - SpringJUnit4ClassRunner constructor called with [class com.example.multi_data_source.MultiDataSourceApplicationTests]
10:35:42.161 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating CacheAwareContextLoaderDelegate from class [org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate]
10:35:42.172 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating BootstrapContext using constructor [public org.springframework.test.context.support.DefaultBootstrapContext(java.lang.Class,org.springframework.test.context.CacheAwareContextLoaderDelegate)]
10:35:42.195 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating TestContextBootstrapper for test class [com.example.multi_data_source.MultiDataSourceApplicationTests] from class [org.springframework.boot.test.context.SpringBootTestContextBootstrapper]
10:35:42.220 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Neither @ContextConfiguration nor @ContextHierarchy found for test class [com.example.multi_data_source.MultiDataSourceApplicationTests], using SpringBootContextLoader
10:35:42.223 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [com.example.multi_data_source.MultiDataSourceApplicationTests]: class path resource [com/example/multi_data_source/MultiDataSourceApplicationTests-context.xml] does not exist
10:35:42.223 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [com.example.multi_data_source.MultiDataSourceApplicationTests]: class path resource [com/example/multi_data_source/MultiDataSourceApplicationTestsContext.groovy] does not exist
10:35:42.223 [main] INFO org.springframework.test.context.support.AbstractContextLoader - Could not detect default resource locations for test class [com.example.multi_data_source.MultiDataSourceApplicationTests]: no resource found for suffixes {-context.xml, Context.groovy}.
10:35:42.225 [main] INFO org.springframework.test.context.support.AnnotationConfigContextLoaderUtils - Could not detect default configuration classes for test class [com.example.multi_data_source.MultiDataSourceApplicationTests]: MultiDataSourceApplicationTests does not declare any static, non-private, non-final, nested classes annotated with @Configuration.
10:35:42.306 [main] DEBUG org.springframework.test.context.support.ActiveProfilesUtils - Could not find an 'annotation declaring class' for annotation type [org.springframework.test.context.ActiveProfiles] and class [com.example.multi_data_source.MultiDataSourceApplicationTests]
10:35:42.425 [main] DEBUG org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider - Identified candidate component class: file [/Users/mike/Desktop/Demos/multi_data_source/target/classes/com/example/multi_data_source/MultiDataSourceApplication.class]
10:35:42.431 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Found @SpringBootConfiguration com.example.multi_data_source.MultiDataSourceApplication for test class com.example.multi_data_source.MultiDataSourceApplicationTests
10:35:42.558 [main] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - @TestExecutionListeners is not present for class [com.example.multi_data_source.MultiDataSourceApplicationTests]: using defaults.
10:35:42.559 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener, org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener]
10:35:42.582 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Using TestExecutionListeners: [org.springframework.test.context.web.ServletTestExecutionListener@72057ecf, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@1afd44cb, org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener@6973b51b, org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener@1ab3a8c8, org.springframework.test.context.support.DirtiesContextTestExecutionListener@43195e57, org.springframework.test.context.transaction.TransactionalTestExecutionListener@333291e3, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener@479d31f3, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener@40ef3420, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener@498d318c, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener@6e171cd7, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener@402bba4f, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener@795cd85e]
10:35:42.585 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [com.example.multi_data_source.MultiDataSourceApplicationTests]
10:35:42.585 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [com.example.multi_data_source.MultiDataSourceApplicationTests]
10:35:42.586 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [com.example.multi_data_source.MultiDataSourceApplicationTests]
10:35:42.586 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [com.example.multi_data_source.MultiDataSourceApplicationTests]
10:35:42.586 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [com.example.multi_data_source.MultiDataSourceApplicationTests]
10:35:42.586 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [com.example.multi_data_source.MultiDataSourceApplicationTests]
10:35:42.594 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [com.example.multi_data_source.MultiDataSourceApplicationTests]
10:35:42.594 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [com.example.multi_data_source.MultiDataSourceApplicationTests]
10:35:42.595 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [com.example.multi_data_source.MultiDataSourceApplicationTests]
10:35:42.595 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [com.example.multi_data_source.MultiDataSourceApplicationTests]
10:35:42.596 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [com.example.multi_data_source.MultiDataSourceApplicationTests]
10:35:42.596 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [com.example.multi_data_source.MultiDataSourceApplicationTests]
10:35:42.601 [main] DEBUG org.springframework.test.context.support.AbstractDirtiesContextTestExecutionListener - Before test class: context [DefaultTestContext@245b4bdc testClass = MultiDataSourceApplicationTests, testInstance = [null], testMethod = [null], testException = [null], mergedContextConfiguration = [WebMergedContextConfiguration@6c64cb25 testClass = MultiDataSourceApplicationTests, locations = '{}', classes = '{class com.example.multi_data_source.MultiDataSourceApplication}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true}', contextCustomizers = set[org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@3fd7a715, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@7f13d6e, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer@27a8c74e, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@52feb982], resourceBasePath = 'src/main/webapp', contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]], attributes = map['org.springframework.test.context.web.ServletTestExecutionListener.activateListener' -> true]], class annotated with @DirtiesContext [false] with mode [null].
10:35:42.601 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [com.example.multi_data_source.MultiDataSourceApplicationTests]
10:35:42.602 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [com.example.multi_data_source.MultiDataSourceApplicationTests]
10:35:42.631 [main] DEBUG org.springframework.test.context.support.TestPropertySourceUtils - Adding inlined properties to environment: {spring.jmx.enabled=false, org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true, server.port=-1}

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.1.3.RELEASE)

2021-01-06 10:35:43.107  INFO 24417 --- [           main] c.e.m.MultiDataSourceApplicationTests    : Starting MultiDataSourceApplicationTests on MikedeiMac.local with PID 24417 (started by mike in /Users/mike/Desktop/Demos/multi_data_source)
2021-01-06 10:35:43.108  INFO 24417 --- [           main] c.e.m.MultiDataSourceApplicationTests    : No active profile set, falling back to default profiles: default
2021-01-06 10:35:43.851  INFO 24417 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.
2021-01-06 10:35:43.872  INFO 24417 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 16ms. Found 0 repository interfaces.
2021-01-06 10:35:44.056  WARN 24417 --- [           main] o.m.s.mapper.ClassPathMapperScanner      : Cannot use both: sqlSessionTemplate and sqlSessionFactory together. sqlSessionFactory is ignored.
2021-01-06 10:35:44.058  WARN 24417 --- [           main] o.m.s.mapper.ClassPathMapperScanner      : Cannot use both: sqlSessionTemplate and sqlSessionFactory together. sqlSessionFactory is ignored.
2021-01-06 10:35:44.339  INFO 24417 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$429f6a58] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-01-06 10:35:45.092  INFO 24417 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2021-01-06 10:35:45.572  INFO 24417 --- [           main] c.e.m.MultiDataSourceApplicationTests    : Started MultiDataSourceApplicationTests in 2.924 seconds (JVM running for 3.863)
2021-01-06 10:35:45.657  INFO 24417 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2021-01-06 10:35:48.925  INFO 24417 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
2021-01-06 10:35:48.932  INFO 24417 --- [           main] o.s.t.c.transaction.TransactionContext   : Began transaction (1) for test context [DefaultTestContext@245b4bdc testClass = MultiDataSourceApplicationTests, testInstance = com.example.multi_data_source.MultiDataSourceApplicationTests@7eae3764, testMethod = test@MultiDataSourceApplicationTests, testException = [null], mergedContextConfiguration = [WebMergedContextConfiguration@6c64cb25 testClass = MultiDataSourceApplicationTests, locations = '{}', classes = '{class com.example.multi_data_source.MultiDataSourceApplication}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true}', contextCustomizers = set[org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@3fd7a715, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@7f13d6e, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer@27a8c74e, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@52feb982], resourceBasePath = 'src/main/webapp', contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]], attributes = map['org.springframework.test.context.web.ServletTestExecutionListener.activateListener' -> true, 'org.springframework.test.context.web.ServletTestExecutionListener.populatedRequestContextHolder' -> true, 'org.springframework.test.context.web.ServletTestExecutionListener.resetRequestContextHolder' -> true]]; transaction manager [org.springframework.jdbc.datasource.DataSourceTransactionManager@10dc7d6]; rollback [true]
2021-01-06 10:35:50.392  INFO 24417 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-2 - Starting...
2021-01-06 10:35:50.395  INFO 24417 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-2 - Start completed.
2021-01-06 10:35:50.648  INFO 24417 --- [           main] o.s.t.c.transaction.TransactionContext   : Rolled back transaction for test: [DefaultTestContext@245b4bdc testClass = MultiDataSourceApplicationTests, testInstance = com.example.multi_data_source.MultiDataSourceApplicationTests@7eae3764, testMethod = test@MultiDataSourceApplicationTests, testException = [null], mergedContextConfiguration = [WebMergedContextConfiguration@6c64cb25 testClass = MultiDataSourceApplicationTests, locations = '{}', classes = '{class com.example.multi_data_source.MultiDataSourceApplication}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true}', contextCustomizers = set[org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@3fd7a715, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@7f13d6e, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer@27a8c74e, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@52feb982], resourceBasePath = 'src/main/webapp', contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]], attributes = map['org.springframework.test.context.web.ServletTestExecutionListener.activateListener' -> true, 'org.springframework.test.context.web.ServletTestExecutionListener.populatedRequestContextHolder' -> true, 'org.springframework.test.context.web.ServletTestExecutionListener.resetRequestContextHolder' -> true]]
2021-01-06 10:35:50.653  INFO 24417 --- [       Thread-2] o.s.s.concurrent.ThreadPoolTaskExecutor  : Shutting down ExecutorService 'applicationTaskExecutor'
2021-01-06 10:35:50.653  INFO 24417 --- [       Thread-2] com.zaxxer.hikari.HikariDataSource       : HikariPool-2 - Shutdown initiated...
2021-01-06 10:35:50.661  INFO 24417 --- [       Thread-2] com.zaxxer.hikari.HikariDataSource       : HikariPool-2 - Shutdown completed.
2021-01-06 10:35:50.661  INFO 24417 --- [       Thread-2] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown initiated...
2021-01-06 10:35:50.664  INFO 24417 --- [       Thread-2] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown completed.

Process finished with exit code 0

代码读出来是有数据的,数据库工具里没数据,primary会回滚,secondary正常

Chapter3-1-1 请求如果是json是否会更好一点

Chapter3-1-1 中是Spring Boot构建RESTful API与单元测试,构造的请求是表单形式而返回的是json。如果请求是json是否会更好一点,可以增加请求为json的说明或者事例(采用RequestBody)。

chapter2-3 校验的错误不显示

发起校验不通过的请求时,确认校验是执行了的,但是没有错误的详细信息。swagger文档中所有的校验都没有体现。请问是什么原因。
图片
图片
图片
图片

SpringBootWithSwagger

Swagger 使用有问题 不能通过Swagger页面进行 putUser deleteUser 有问题

Need help to read the tutorial from your website.

Hello @dyc87112 , I think this is a really good tutorial. I want to learn spring boot but your tutorial is in the Chinese language, I am converting all the pages into English using a google translate extension. it is ok. but when I click on Read the full button to read the full article it opens one qrcode dialog. then what to do I don't understand. when I scan it opens one URL on my mobile. and there is no login-related functionality on the website.
Could you please guide us on how to read the full article?
qrcode

Chapter3-1-2 代码问题

Chapter3-1-2/src/main/java/com/didispace/web/HelloController.java

这里的ResponseBody是不是应该去掉?

    @ResponseBody
    @RequestMapping("/hello")
    public String hello() {
        return "Hello World";
    }

flyway

为什么一模一样的例子 却不创建表呢?

第一章节

import org.springframework.http.MediaType;
导入这个包为什么报错啊

chapter 2-2

为啥UserController 中的getID() setName, setAge都标红

3-7配置jdbcTempalte多数据源里的配置文件两个jdbcTemplate对象不会覆盖吗

@bean
public JdbcTemplate primaryJdbcTemplate(@qualifier("primaryDataSource") DataSource primaryDataSource) {
return new JdbcTemplate(primaryDataSource);
}

@Bean
public JdbcTemplate secondaryJdbcTemplate(@Qualifier("secondaryDataSource") DataSource secondaryDataSource) {
    return new JdbcTemplate(secondaryDataSource);
}

上面是配置文件里的代码,这样写不会覆盖吗,容器里毕竟只能有一个JdbcTemplate类型的对象

springboot+mybatis使用问题

数据库表名有前缀,用下划线链接 并且使用generator自动生成代码 。 但是生成不了有下划线的表实体类 这种情况怎么处理啊

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.