@Component
@ConfigurationProperties(prefix = "spring.dataSource.primaryDataSource")
public class DuridBeans {
private String type;
private String url;
private String username;
private String password;
private String driverClassName;
private Integer initialSize;
private Integer minIdle;
private Integer maxActive;
private Integer maxWait;
private Integer timeBetweenEvictionRunsMillis;
private Integer minEvictableIdleTimeMillis;
private String validationQuery;
private Boolean testWhileIdle;
private Boolean testOnBorrow;
private Boolean testOnReturn;
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getDriverClassName() {
return driverClassName;
}
public void setDriverClassName(String driverClassName) {
this.driverClassName = driverClassName;
}
public Integer getInitialSize() {
return initialSize;
}
public void setInitialSize(Integer initialSize) {
this.initialSize = initialSize;
}
public Integer getMinIdle() {
return minIdle;
}
public void setMinIdle(Integer minIdle) {
this.minIdle = minIdle;
}
public Integer getMaxActive() {
return maxActive;
}
public void setMaxActive(Integer maxActive) {
this.maxActive = maxActive;
}
public Integer getMaxWait() {
return maxWait;
}
public void setMaxWait(Integer maxWait) {
this.maxWait = maxWait;
}
public Integer getTimeBetweenEvictionRunsMillis() {
return timeBetweenEvictionRunsMillis;
}
public void setTimeBetweenEvictionRunsMillis(Integer timeBetweenEvictionRunsMillis) {
this.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis;
}
public Integer getMinEvictableIdleTimeMillis() {
return minEvictableIdleTimeMillis;
}
public void setMinEvictableIdleTimeMillis(Integer minEvictableIdleTimeMillis) {
this.minEvictableIdleTimeMillis = minEvictableIdleTimeMillis;
}
public String getValidationQuery() {
return validationQuery;
}
public void setValidationQuery(String validationQuery) {
this.validationQuery = validationQuery;
}
public Boolean getTestWhileIdle() {
return testWhileIdle;
}
public void setTestWhileIdle(Boolean testWhileIdle) {
this.testWhileIdle = testWhileIdle;
}
public Boolean getTestOnBorrow() {
return testOnBorrow;
}
public void setTestOnBorrow(Boolean testOnBorrow) {
this.testOnBorrow = testOnBorrow;
}
public Boolean getTestOnReturn() {
return testOnReturn;
}
public void setTestOnReturn(Boolean testOnReturn) {
this.testOnReturn = testOnReturn;
}
}
@Configuration
public class DuridSource {
@Autowired
private DuridBeans druidPrimaryDataSourceConfigProperties;
@Bean(name="dataSource")
@Primary
public DataSource primaryDataSource (){
DruidDataSource datasource = new DruidDataSource();
datasource.setUrl(this.druidPrimaryDataSourceConfigProperties.getUrl());
datasource.setUsername(this.druidPrimaryDataSourceConfigProperties.getUsername());
datasource.setPassword(this.druidPrimaryDataSourceConfigProperties.getPassword());
datasource.setDriverClassName(this.druidPrimaryDataSourceConfigProperties.getDriverClassName());
datasource.setInitialSize(this.druidPrimaryDataSourceConfigProperties.getInitialSize());
datasource.setMinIdle(this.druidPrimaryDataSourceConfigProperties.getMinIdle());
datasource.setMaxActive(this.druidPrimaryDataSourceConfigProperties.getMaxActive());
datasource.setMaxWait(this.druidPrimaryDataSourceConfigProperties.getMaxWait());
datasource.setTimeBetweenEvictionRunsMillis(this.druidPrimaryDataSourceConfigProperties.getTimeBetweenEvictionRunsMillis());
datasource.setMinEvictableIdleTimeMillis(this.druidPrimaryDataSourceConfigProperties.getMinEvictableIdleTimeMillis());
datasource.setValidationQuery(this.druidPrimaryDataSourceConfigProperties.getValidationQuery());
datasource.setTestWhileIdle(this.druidPrimaryDataSourceConfigProperties.getTestWhileIdle());
datasource.setTestOnBorrow(this.druidPrimaryDataSourceConfigProperties.getTestOnBorrow());
datasource.setTestOnReturn(this.druidPrimaryDataSourceConfigProperties.getTestOnReturn());
return datasource;
}
}
@Configuration
public class MybatisConfig {
@Autowired
private DataSource dataSource; //Durid数据源
@Bean
public SqlSessionFactoryBean createSqlSessionFactoryBean() throws Exception {
SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
sqlSessionFactoryBean.setDataSource(dataSource);
org.apache.ibatis.session.Configuration config=new org.apache.ibatis.session.Configuration();
config.setMapUnderscoreToCamelCase(true); //设置驼峰命名
sqlSessionFactoryBean.setConfiguration(config);
sqlSessionFactoryBean.setTypeAliasesPackage("com.ws.bean");
Interceptor[] plugins = new Interceptor[]{pageHelper()};
sqlSessionFactoryBean.setPlugins(plugins);
return sqlSessionFactoryBean;
}
/**
* Mybatis分页插件
*/
@Bean
public PageHelper pageHelper() {
PageHelper pageHelper = new PageHelper();
Properties p = new Properties();
p.setProperty("offsetAsPageNum", "true");
p.setProperty("rowBoundsWithCount", "true");
p.setProperty("reasonable", "true");
pageHelper.setProperties(p);
return pageHelper;
}
public interface UserMapper {
@Select({"SELECT * FROM USER_TEST"})
List getUserInfo();
}
@Service
public class UserService {
@Autowired
private UserMapper userMapper;
public List getUserInfoSer(){
return userMapper.getUserInfo();
}
}
@RestController
public class UserController {
@Autowired
private UserService userService;
@RequestMapping(value="/test" ,method= RequestMethod.GET)
public String testGetUserInfo() {
User user=userService.getUserInfoSer().get(0);
return "我是"+user.getUserName()+"今年"+user.getUserAge()+"岁了!";
}
}
说明:关于Durid数据源的配置这里就不详细说明了,springboot默认使用tomcat的数据源,在使用tomcat数据源部署的时候报错(NO supported Datasource type found),然后就给换成durid数据源。
java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.View.getImportantForAccessibility()' on a null object reference
出现以上异常.然后就在baidu上
cmd命令打jar是如下实现:
在运行里输入cmd,利用cmd命令进入到本地的工作盘符。(如我的是D盘下的文件有此路径 D:\workspace\prpall\WEB-INF\classes)
现在是想把D:\workspace\prpall\WEB-INF\classes路径下所有的文件打包成prpall.jar。然后继续如下操作:
cd D: 回车
cd workspace/prpal
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml&q
Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area.
public class Solution {
public int maximalRectangle(char[][] matrix)
随着RESTful Web Service的流行,测试对外的Service是否满足期望也变的必要的。从Spring 3.2开始Spring了Spring Web测试框架,如果版本低于3.2,请使用spring-test-mvc项目(合并到spring3.2中了)。
Spring MVC测试框架提供了对服务器端和客户端(基于RestTemplate的客户端)提供了支持。
&nbs
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
/*you'll also need to set UIViewControllerBasedStatusBarAppearance to NO in the plist file if you use this method
英文资料:
Thread Dump and Concurrency Locks
Thread dumps are very useful for diagnosing synchronization related problems such as deadlocks on object monitors. Ctrl-\ on Solaris/Linux or Ctrl-B