
springboot
pilaf1990
操千曲而后晓声,观千剑而后识器~
展开
-
Gson序列化忽略某个字段和mongodb忽略某个字段
在应用中需要将实体类分别发送到kafka和插入mongodb中。 重写了实体类的toString方法: private static final Gson gson = new Gson(); @Override public String toString() { return gson.toJson(this); }发送kafka的时候...原创 2018-07-19 14:42:28 · 4314 阅读 · 0 评论 -
Spring Boot获取依赖项目中定义的bean
在A项目中定义类了一些bean,并用Spring的@Component注解标识了。在B项目中引用了A项目,即在pom.xml的dependency中添加了项目A。在SpringBoot启动的时候报找不到A项目中的bean。因为SpringBoot的启动Application的默认的ComponentScan的范围中没有包含A项目的bean所在的package路径。 在B项目中增加@C...原创 2018-08-09 14:07:20 · 1991 阅读 · 0 评论 -
Spring Boot读取yml配置信息到配置对象
       Spring Boot允许配置外部化,这样同样的代码可以运行在不同的环境中,比如生产环境、测试环境用同一套代码,但是连的数据库信息可以放在应用的外部。可以使用properties文件,ymal文件,环境变量和命令行参数来使得配置外部化。属性值可以通过@Value注入到bean中,或者通过Spring的环境变量拿到配原创 2018-08-09 20:25:29 · 12433 阅读 · 1 评论 -
application.yml中使用@获取maven pom.xml properties运行单元测试报错问题
application.yml文件中用@@引用maven的pom.xml文件中的属性yml文件中的内容:server: port: @server_port@maven的pom.xml文件中的内容:<profiles> <profile> ... <properties> <se...原创 2019-01-28 17:19:47 · 7231 阅读 · 3 评论 -
springboot+dubbo报错Can not set XX field YY to org.apache.dubbo.common.bytecode.proxy0
报错信息:Caused by: java.lang.IllegalArgumentException: Can not set XX field YY to org.apache.dubbo.common.bytecode.proxy0 at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeF...原创 2019-02-15 14:27:02 · 4021 阅读 · 0 评论 -
springboot maven "lib"模块的单元测试
由于在springboot maven的项目中分了模块,对于dao层模块来说,它没有@SpringBootApplication修饰的启动类,也就是说这个模块是没有spring ApplicationContext的,在单元测试的时候,报了错误:java.lang.IllegalStateException: ...原创 2019-03-29 17:41:24 · 505 阅读 · 0 评论 -
springboot+mybatis打包时,单元测试类报错
报错信息:2019-04-01 14:33:10.703 ERROR 1957 --- [ main] o.s.test.context.TestContextManager : Caught exception while allowing TestExecutionListener [org.springframework.boot.test.mock.mock...原创 2019-04-01 14:45:33 · 3374 阅读 · 0 评论 -
解决springboot maven多模块项目打包的时候某个被依赖的模块报错找不到main class
springboot maven 多模块项目打包的时候某个被依赖的模块报错[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.1.3.RELEASE:repackage (repackage) on project **-client: Execution repackage of...原创 2019-03-29 11:59:11 · 8819 阅读 · 5 评论 -
SpringBoot单元测试@SpyBean的方法被模拟却仍然进入的问题
在SpringBoot中用@SpyBean来表示一个“间谍对象”,允许它的某些方法被模拟,而剩下的方法仍然是真实的方法。import com.**.hydra.account.HydraAccountApplication;import com.**.hydra.account.config.DataSourceConfiguration;import com.**.hydra.clien...原创 2019-04-26 20:09:45 · 6828 阅读 · 0 评论