共 35 篇文章 |
|
Spring Boot 2.x基础教程:使用国产数据库连接池Druid | 程序猿DD.配置Druid监控。spring.datasource.druid.stat-view-servlet.enabled=truespring.datasource.druid.stat-view-servlet.url-pattern=/druid/*spring.datasource.druid.stat-view-servlet.reset-enable=truespring.datasource.druid.stat-view-servlet.login-username=adminsprin... 阅56 转0 评0 公众公开 20-10-09 11:19 |
springboot 获取enviroment.Properties的几种方式。springboot获取配置资源,主要分3种方式:@Value、 @ConfigurationProperties、Enviroment对象直接调用。2.4也能发现Enviroment new的PropertyResolver是PropertySourcesPropertyResolver@ConfigurationProperties实现原理。> target) { ConfigurationProperties annotation = target .get... 阅437 转1 评0 公众公开 20-06-02 20:19 |
方法五:实现接口ApplicationContextAware说明:实现该接口的setApplicationContext(ApplicationContext context)方法,并保存ApplicationContext 对象。虽 然,spring提供了后三种方法可以实现在普通的类中继承或实现相应的类或接口来获取spring 的ApplicationContext对象,但是在使用是一定要注意实现了这些类或接口的普通java类一定要在Spri... 阅169 转0 评0 公众公开 20-03-25 09:03 |
信息在资源文件以属性名/值的方式表示:上面的例子中,假设我们使用ResourceBundle.getBundle(“com/baobaotao/i18n/resource”,Locale.CANADA)加载资源,由于不存在resource_en_CA.properties资源文件,它将尝试加载resource_zh_CN.properties的资源文件,假设resource_zh_CN.properties资源文件也不存在,它将继续尝试加载resource.propertie... 阅103 转1 评0 公众公开 20-03-23 09:16 |
SpringBoot在Maven环境下如何使用自己项目的parent?spring-boot-starter-parent的作用::<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.8.<dependencyManagement> <dependencies> <dependency> <... 阅300 转0 评0 公众公开 20-02-13 11:17 |
这个时候,业务异常类:public class BusinessException extends RuntimeException{private static final long serialVersionUID = 1L;private Integer code; //错误码public BusinessException() {}public BusinessException(ResultEnum resultEnum) {super(resultEnum.getMsg());this.code = resultEnum.getCode();}public Integer getCode()... 阅234 转2 评0 公众公开 19-12-10 23:00 |
3 </bean>而基于JavaConfig的配置形式是这样的:1 @Configuration2 public class MockConfiguration{3 @Bean4 public MockService mockService(){5 return new MockServiceImpl();6 }7 }任何一个标注了@Bean的方法,其返回值将作为一个bean定义注册到Spring的IoC容器,方法名将默认成该bean定义的id。@EnableSchedul... 阅33 转0 评0 公众公开 19-12-05 19:43 |
SpringBoot session超时的问题。最近在做SpringBoot的项目,用到了session,发现放置好session后,过一会就失效了,用下面发语句获取session失效时间,发现是60srequest.getSession().getMaxInactiveInterval();这里重点解释一下 PT5H 意思是设置session失效的时间是5小时通过查看setTimeouot的方法,这里要求传入Duration的实例public void se... 阅111 转0 评0 公众公开 19-09-30 17:23 |
springboot session会话超时设置(九)springboot session会话超时设置(九) 点关注不迷路,欢迎再来!接下来时间经过反复查找问题发现是Tomcat中web.xml中session-out设置为30分,原来是因为在测试环境启动项目未使用Tomcat,所以项目中application.yaml配置session-out是生效的。-- 时间单位为分钟 --> <session-config> <session-t... 阅4053 转0 评0 公众公开 19-09-30 10:31 |
><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><parent><groupId>... 阅27 转0 评0 公众公开 19-09-20 14:01 |