SpringBoot+MyBaits+MySQL连接数据库出错,求大神指点配置

报错如下:
2017-11-19 15:13:40.009 ERROR 15152 --- [nio-8090-exec-2] e.n.y.o.service.LoginModuleService : checkUserInfo: Error message is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:

Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)

The error may exist in file [D:\Spring\JavaWeb\OnlineBookstore\target\classes\mybatis\mapper\UserInfoMapper.xml]

The error may involve edu.javaee.onlinebookstore.mapper.UserInfoMapper.isNameExist

The error occurred while executing a query

Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)

application.properties配置如下:
server.port = 8090
spring.mvc.view.prefix = /WEB-INF/jsp/
spring.mvc.view.suffix = .jsp
spring.datasource.driverClassName = com.mysql.jdbc.Driver
spring.datasource.url = jdbc:mysql://localhost:3306/onlinebookstore?useUnicode=true&characterEncoding=utf8&useSSL=false
spring.datasource.username = root
spring.datasource.password = root
mybatis.typeAliasesPackage = edu.javaee.onlinebookstore.domain
mybatis.config-location = classpath:mybatis/mybatis-config.xml
mybatis.mapper-locations = classpath:mybatis/mapper/*Mapper.xml
logging.file = log/service.log
检查过数据库密码正确,可以通过Navicat访问。

3个回答

update user set password=PASSWORD("123456") where user='root';
用navicat连接数据库重设一下数据库的登录密码。然后重启mysql服务。再试试。

  Access denied for user 'root'@'localhost' (using password: YES)

这是密码不符啊, 你瞅瞅你本地mysql有密码不,密码是什么?

1 密码不正确
2 用户权限配置不正确

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
SpringBoot+MyBaits+MySQL连接数据库出错,求大神指点配置

报错如下: 2017-11-19 15:13:40.009 ERROR 15152 --- [nio-8090-exec-2] e.n.y.o.service.LoginModuleService : checkUserInfo: Error message is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES) ### The error may exist in file [D:\Spring\JavaWeb\OnlineBookstore\target\classes\mybatis\mapper\UserInfoMapper.xml] ### The error may involve edu.javaee.onlinebookstore.mapper.UserInfoMapper.isNameExist ### The error occurred while executing a query ### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES) application.properties配置如下: server.port = 8090 spring.mvc.view.prefix = /WEB-INF/jsp/ spring.mvc.view.suffix = .jsp spring.datasource.driverClassName = com.mysql.jdbc.Driver spring.datasource.url = jdbc:mysql://localhost:3306/onlinebookstore?useUnicode=true&characterEncoding=utf8&useSSL=false spring.datasource.username = root spring.datasource.password = root mybatis.typeAliasesPackage = edu.javaee.onlinebookstore.domain mybatis.config-location = classpath:mybatis/mybatis-config.xml mybatis.mapper-locations = classpath:mybatis/mapper/*Mapper.xml logging.file = log/service.log 检查过数据库密码正确,可以通过Navicat访问。

spring boot 如何配置远程访问 带有ssh通道的数据库(mysql)

数据库服务器带有ssh通道,通过navicat软件可以访问数据库(使用ssh方式), 可是spring boot工程中如何连接访问呢。

mybaits连接数据库连接超时

我用jdbc可以连,刚要开始自学mybaits就碰到了这个问题解决不了,求各位大佬帮忙。

springboot+mybatis 项目 配置多个数据源(mysql和oracle)出错,请大神帮忙看看,急急急!!!跪谢!!!

![图片说明](https://img-ask.csdn.net/upload/201901/16/1547628653_376131.png)![图片说明](https://img-ask.csdn.net/upload/201901/16/1547628662_153121.png)![图片说明](https://img-ask.csdn.net/upload/201901/16/1547628667_342638.png)![图片说明](https://img-ask.csdn.net/upload/201901/16/1547628673_748493.png)![图片说明](https://img-ask.csdn.net/upload/201901/16/1547628677_135355.png)![图片说明](https://img-ask.csdn.net/upload/201901/16/1547628683_140741.png)![图片说明](https://img-ask.csdn.net/upload/201901/16/1547628688_707663.png)![图片说明](https://img-ask.csdn.net/upload/201901/16/1547628692_160621.png)![图片说明](https://img-ask.csdn.net/upload/201901/16/1547628697_604537.png)

Springboot下mybatis如何配置databaseId

Springboot设置了mybatis.config-location,然后在mybatis-config.xml下配置了databaseIdProvider type="DB_VENDOR" <databaseIdProvider type="DB_VENDOR"> <property name="DB2" value="db2"/> <property name="Oracle" value="oracle" /> <property name="Adaptive Server Enterprise" value="sybase"/> <property name="MySQL" value="mysql" /> </databaseIdProvider> 但是不会生效,调试发现初始化时由于Database是在application.propertities下定义的,mybatis初始化时会检测Environment是否为null,为null则不设置databaseId,在Spring下知道如何配置,但是SpringBoot下搞不定,求大神指点

springboot中通过mybatis访问数据,打成jar包后,就出现数据库url未空的异常。

问题是这样的,我刚接触springboot,做了一个springboot的工程,需要通过mybatis访问oracle数据库,数据库的连接信息写在application.properties文件的spring.datasource中。在eclipse上直接运行程序,数据库访问正常,但是打成jar包后,读数据出现异常: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: The url cannot be null 就不能读取数据库。 我解开jar包看,Application.properties也在classes路径下的。 另外,application类中设置数据源是这么写的: ``` @Bean @ConfigurationProperties(prefix = "spring.datasource") public DataSource dataSource() { DataSource dataSource = new org.apache.tomcat.jdbc.pool.DataSource(); System.out.println(dataSource.getUrl()); return dataSource; } @Bean public SqlSessionFactory sqlSessionFactoryBean() throws Exception { SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean(); sqlSessionFactoryBean.setDataSource(dataSource()); ``` 我把dataSource里面的url打印出来看,不管是在eclipse运行的时候,还是jar包运行的时候都是null,但eclipse运行时虽然是null,但功能正常。 网上搜索了很多帖子没有能解决这个问题,请专家帮忙看看也。谢谢。

springboot+mybatis切换数据源问题

# 问题描述 springboot+mybatis想实现oracle和Mysql数据库切换,目前用 Mysql作为 主数据源时, 可以正常查询;用Oracle作为主数据源时,也可以正常查询;目前想实现,Mysql作为主数据源时,也可以切换到另外一个数据源。 # 相关代码如下 ## 创建数据源 ### 创建Mysql数据源 ``` @Bean(name = "dataSource") @Primary public ComboPooledDataSource createDataSource() throws PropertyVetoException { ComboPooledDataSource comboPooledDataSource = new ComboPooledDataSource(); comboPooledDataSource.setDriverClass(jdbcDriver); comboPooledDataSource.setJdbcUrl(jdbcUrl); comboPooledDataSource.setUser(jdbcUsername); comboPooledDataSource.setPassword(jdbcPassword); //连接关闭不自动提交 comboPooledDataSource.setAutoCommitOnClose(false); return comboPooledDataSource; } @Bean(name="sqlSessionFactory") @Primary public SqlSessionFactoryBean createSqlSessionFactoryBean(@Qualifier("dataSource") DataSource dataSource) throws IOException { SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean(); sqlSessionFactoryBean.setConfigLocation(new ClassPathResource(mybatisConfigFilePath)); PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); String packageSearchPath = PathMatchingResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + mapperPath; sqlSessionFactoryBean.setMapperLocations(resolver.getResources(packageSearchPath)); sqlSessionFactoryBean.setDataSource(dataSource); sqlSessionFactoryBean.setTypeAliasesPackage(entityPackage); return sqlSessionFactoryBean; } ``` ### 创建oracle数据源 ``` @Bean(name="oracleDataSource") public ComboPooledDataSource createOracleDataSource() throws PropertyVetoException { ComboPooledDataSource comboPooledOracleDataSource = new ComboPooledDataSource(); comboPooledOracleDataSource.setDriverClass(oracleJdbcDriver); comboPooledOracleDataSource.setJdbcUrl(oracleJdbcUrl); comboPooledOracleDataSource.setUser(oracleJdbcUser); comboPooledOracleDataSource.setPassword(oracleJdbcPassword); comboPooledOracleDataSource.setAutoCommitOnClose(false); return comboPooledOracleDataSource; } @Bean(name="oracleSqlSessionFactory") public SqlSessionFactoryBean createSqlSessionFactoryBean(@Qualifier("oracleDataSource") DataSource oracleDataSource) throws IOException { SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean(); sqlSessionFactoryBean.setConfigLocation(new ClassPathResource(mybatisConfigFilePath)); PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); String packageSearchPath = PathMatchingResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + oracleMapperPath; sqlSessionFactoryBean.setMapperLocations(resolver.getResources(packageSearchPath)); sqlSessionFactoryBean.setDataSource(oracleDataSource); sqlSessionFactoryBean.setTypeAliasesPackage(entityPackage); return sqlSessionFactoryBean; } ``` ## 事物管理代码段 ``` @Autowired @Qualifier("dataSource") private DataSource dataSource; @Autowired @Qualifier("oracleDataSource") private DataSource oracleDataSource; @Bean(name="localMysql") public PlatformTransactionManager localMysqlManager(){ return new DataSourceTransactionManager(dataSource); } @Bean(name="localOracle") public PlatformTransactionManager oracleManager(){ return new DataSourceTransactionManager(oracleDataSource); } ``` ## 切换数据源代码段 ``` @Override @Transactional(value = "localOracle") public List<Map> listOracle() { return helloOracleDao.listHello(); } ``` # 问题 感觉数据源创建什么的都没问题,但是最后一步切换不生效,不知道什么问题,还请大神赐教

springboot mybatis 动态表名后缀配置

比如现在数据库有不同版本的用户表 user_v1.5 ,user_v1.6,user_v1.7 现在我想通过配置,来读取不同版本的表 (配置v1.5 程序全局就读取user_v1.5这张表)

使用Mybaits存储图片存储到数据库中代码

使用Mybaits存储图片存储到数据库中代码 先要将其转换成二进制

springboot+mybatis(xml模式) 项目 单元测试 报错。

2017-09-01 17:35:21.034 INFO 11212 --- [ main] com.alibaba.druid.pool.DruidDataSource : {dataSource-1} inited org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.lxhw.module.jbxx.dao.DjKjfCzryDao.getCzry at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:230) at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:48) at org.apache.ibatis.binding.MapperProxy.cachedMapperMethod(MapperProxy.java:65) at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:58) at com.sun.proxy.$Proxy98.getCzry(Unknown Source) at com.lxhw.module.jbxx.service.DjKjfCzryService.getCzry(DjKjfCzryService.java:47) at com.lxhw.module.jbxx.service.DjKjfCzryService$$FastClassBySpringCGLIB$$30938009.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:738) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:282) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:673) at com.lxhw.module.jbxx.service.DjKjfCzryService$$EnhancerBySpringCGLIB$$428d2624.getCzry(<generated>) at com.lxhw.module.jbxx.service.DjKjfCzryServiceTest.searchCzry(DjKjfCzryServiceTest.java:21) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:252) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68) at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70) 这个是报错信息 项目运行正常,就是不能单元测试 初步估计是DjKjfCzryDao.class和DjKjfCzryDao.xml没有匹配上。但是run application是正常的,只有junit的时候有问题 是不是和引入mybais-spring-boot-starter有关系,不能自动去取配置文件了。

用springboot+mybatis取出数据contant字段总是显示null(查了一下午debug没找出来)

实现类 ``` public Page<Person> getNewPersonList( Integer currentPage, Integer pageSize) { // 实例化查询条件 final PersonExample personExample = new PersonExample(); PersonExample.Criteria criteria = personExample.createCriteria(); criteria.andIsDeleteEqualTo((byte)0); // 获取查询结果集 Page<Person> result = PageHelper.startPage(currentPage, pageSize).doSelectPage(new ISelect() { @Override public void doSelect() { // personRepository.selectByExample(personExample); personRepository.selectByExample(personExample); } }); return result; } ``` 其中返回值得实体类的代码: ``` package com.ebiz.code.repository.api.entity; import java.util.Date; public class Person { /** * * This field was generated by MyBatis Generator. * This field corresponds to the database column ebiz_person.id * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ private Integer id; /** * * This field was generated by MyBatis Generator. * This field corresponds to the database column ebiz_person.name * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ private String name; /** * * This field was generated by MyBatis Generator. * This field corresponds to the database column ebiz_person.duty * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ private String duty; /** * * This field was generated by MyBatis Generator. * This field corresponds to the database column ebiz_person.Email * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ private String email; /** * * This field was generated by MyBatis Generator. * This field corresponds to the database column ebiz_person.phone * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ private String phone; /** * * This field was generated by MyBatis Generator. * This field corresponds to the database column ebiz_person.place * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ private String place; /** * * This field was generated by MyBatis Generator. * This field corresponds to the database column ebiz_person.is_delete * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ private Byte isDelete; /** * * This field was generated by MyBatis Generator. * This field corresponds to the database column ebiz_person.create_time * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ private Date createTime; /** * * This field was generated by MyBatis Generator. * This field corresponds to the database column ebiz_person.update_time * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ private Date updateTime; /** * * This field was generated by MyBatis Generator. * This field corresponds to the database column ebiz_person.photo * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ private String photo; /** * * This field was generated by MyBatis Generator. * This field corresponds to the database column ebiz_person.type * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ private Byte type; /** * * This field was generated by MyBatis Generator. * This field corresponds to the database column ebiz_person.contant * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ private String contant; /** * This method was generated by MyBatis Generator. * This method returns the value of the database column ebiz_person.id * * @return the value of ebiz_person.id * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ public Integer getId() { return id; } /** * This method was generated by MyBatis Generator. * This method sets the value of the database column ebiz_person.id * * @param id the value for ebiz_person.id * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ public void setId(Integer id) { this.id = id; } /** * This method was generated by MyBatis Generator. * This method returns the value of the database column ebiz_person.name * * @return the value of ebiz_person.name * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ public String getName() { return name; } /** * This method was generated by MyBatis Generator. * This method sets the value of the database column ebiz_person.name * * @param name the value for ebiz_person.name * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ public void setName(String name) { this.name = name; } /** * This method was generated by MyBatis Generator. * This method returns the value of the database column ebiz_person.duty * * @return the value of ebiz_person.duty * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ public String getDuty() { return duty; } /** * This method was generated by MyBatis Generator. * This method sets the value of the database column ebiz_person.duty * * @param duty the value for ebiz_person.duty * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ public void setDuty(String duty) { this.duty = duty; } /** * This method was generated by MyBatis Generator. * This method returns the value of the database column ebiz_person.Email * * @return the value of ebiz_person.Email * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ public String getEmail() { return email; } /** * This method was generated by MyBatis Generator. * This method sets the value of the database column ebiz_person.Email * * @param email the value for ebiz_person.Email * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ public void setEmail(String email) { this.email = email; } /** * This method was generated by MyBatis Generator. * This method returns the value of the database column ebiz_person.phone * * @return the value of ebiz_person.phone * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ public String getPhone() { return phone; } /** * This method was generated by MyBatis Generator. * This method sets the value of the database column ebiz_person.phone * * @param phone the value for ebiz_person.phone * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ public void setPhone(String phone) { this.phone = phone; } /** * This method was generated by MyBatis Generator. * This method returns the value of the database column ebiz_person.place * * @return the value of ebiz_person.place * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ public String getPlace() { return place; } /** * This method was generated by MyBatis Generator. * This method sets the value of the database column ebiz_person.place * * @param place the value for ebiz_person.place * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ public void setPlace(String place) { this.place = place; } /** * This method was generated by MyBatis Generator. * This method returns the value of the database column ebiz_person.is_delete * * @return the value of ebiz_person.is_delete * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ public Byte getIsDelete() { return isDelete; } /** * This method was generated by MyBatis Generator. * This method sets the value of the database column ebiz_person.is_delete * * @param isDelete the value for ebiz_person.is_delete * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ public void setIsDelete(Byte isDelete) { this.isDelete = isDelete; } /** * This method was generated by MyBatis Generator. * This method returns the value of the database column ebiz_person.create_time * * @return the value of ebiz_person.create_time * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ public Date getCreateTime() { return createTime; } /** * This method was generated by MyBatis Generator. * This method sets the value of the database column ebiz_person.create_time * * @param createTime the value for ebiz_person.create_time * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ public void setCreateTime(Date createTime) { this.createTime = createTime; } /** * This method was generated by MyBatis Generator. * This method returns the value of the database column ebiz_person.update_time * * @return the value of ebiz_person.update_time * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ public Date getUpdateTime() { return updateTime; } /** * This method was generated by MyBatis Generator. * This method sets the value of the database column ebiz_person.update_time * * @param updateTime the value for ebiz_person.update_time * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ public void setUpdateTime(Date updateTime) { this.updateTime = updateTime; } /** * This method was generated by MyBatis Generator. * This method returns the value of the database column ebiz_person.photo * * @return the value of ebiz_person.photo * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ public String getPhoto() { return photo; } /** * This method was generated by MyBatis Generator. * This method sets the value of the database column ebiz_person.photo * * @param photo the value for ebiz_person.photo * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ public void setPhoto(String photo) { this.photo = photo; } /** * This method was generated by MyBatis Generator. * This method returns the value of the database column ebiz_person.type * * @return the value of ebiz_person.type * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ public Byte getType() { return type; } /** * This method was generated by MyBatis Generator. * This method sets the value of the database column ebiz_person.type * * @param type the value for ebiz_person.type * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ public void setType(Byte type) { this.type = type; } /** * This method was generated by MyBatis Generator. * This method returns the value of the database column ebiz_person.contant * * @return the value of ebiz_person.contant * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ public String getContant() { return contant; } /** * This method was generated by MyBatis Generator. * This method sets the value of the database column ebiz_person.contant * * @param contant the value for ebiz_person.contant * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ public void setContant(String contant) { this.contant = contant; } } ``` 数据库图字段没写错 ![图片说明](https://img-ask.csdn.net/upload/201905/11/1557568172_353594.png)

mybaits的model中如何通过注解忽略非数据库字段?

记得那里看到过...忘记了... 比如id是在表中的数据 @Column(name="xxx") private Integer id; name并不是表中的数据,必须忽略它,这个注解是什么?(百度了半天没百度到)

用springboot+freemarker+mybatis写一个登录和注册,和找回密码的界面

这是数据库的代码 create table `tb_user` ( `user_id` int(100) not null auto_increment comment'用户表id', `user_name` varchar(200) not null comment'用户名', `user_password` varchar(1000)not null comment'用户密码', `user_phone` varchar(1000) not null, `user_type`int(10)not null comment'用户类型', `user_email`varchar(2000) default null, `user_quesion`varchar(2000)default null comment'找回密码问题', `user_answer`varchar(2000)default null comment'找回密码答案', `create_time` datetime default null comment'创建时间', `last_edit_time` datetime default null comment'更新时间', primary key(`user_id`), unique key `user_name_unique`(`user_name`)using btree ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

换成数据源连接数据库后,为什么结果就查询不到了?

这是查询方法: ![图片说明](https://img-ask.csdn.net/upload/201811/28/1543418692_239750.png) 之前数据库的配置: ![图片说明](https://img-ask.csdn.net/upload/201811/28/1543418720_861392.png) 允许后的结果正确: ![图片说明](https://img-ask.csdn.net/upload/201811/28/1543418753_271804.png) 更改数据库后: ![图片说明](https://img-ask.csdn.net/upload/201811/28/1543418826_941722.png) 然后结果没有正确显示,但是没有报错正常运行: ![图片说明](https://img-ask.csdn.net/upload/201811/28/1543418982_965040.png) 俩个数据库的配置信息肯定是一样的,我从复制源上粘贴下来的。 求求大哥大姐们,救救我吧。 这个是配置文件: ![图片说明](https://img-ask.csdn.net/upload/201811/28/1543419285_624334.png)

Springboot+Mybatis查询空指针

数据库字段设计 ![图片说明](https://img-ask.csdn.net/upload/201805/26/1527346499_571715.png) 实体类编写 均有get和set方法 ![图片说明](https://img-ask.csdn.net/upload/201805/26/1527346523_530253.png) dao层方法 ![图片说明](https://img-ask.csdn.net/upload/201805/26/1527346538_177283.png) 进行测试时候报错 ![图片说明](https://img-ask.csdn.net/upload/201805/26/1527346556_978861.png)

大佬们 mybatis使用ssl 连接mysql怎么配置 有知道的吗?

![图片说明](https://img-ask.csdn.net/upload/201909/06/1567739384_373478.png)

springboot里面注解mybatis一对一无法自动映射

@Select(" SELECT * FROM buy_car WHERE user_id=#{user_id}") @Results({ @Result(column = "pro_Id",property = "productInfo", one=@One(select = "com.order.dao.ProductMapper.ProInfoByCar"))}) public ArrayList<BuyCar> CarInfoByUser(@Param("user_id")int user_id); 实现根据用户查找购物车的同时查出购物车里面商品的信息,运行无问题,购物车类里面的商品信息类里面可以拿到的,反而购物类本身的字段无法自动映射过去,需要手动在上面继续写result ArrayList<BuyCar> list=productService.CarInfoByUser(user.getUserId()) ; for (BuyCar buyCar : list) { System.out.println(buyCar.getBuy_time());//为空,无法映射,但是sql语句查询出来了 System.out.println(buyCar.getProductInfo().getPro_Name());//有拿到 System.out.println(buyCar.getProductInfo().getPro_logo()); } 购物车类 public class BuyCar { private Integer user_id;//拿不到 private Integer pro_id;//拿不到 private Integer buy_count;//拿不到 private Date buy_time;//拿不到 private ProductInfo productInfo;//自动映射到了 省略getset方法

springboot+mybatis+db2+vue

问题是这样的springboot+mybatis连接db2查询数据库 要1分钟有4600条数据 我看了看写的代码 用了javafor循环递归查询子机构 我改成数据库递归有就快了10几秒 在改成异步还是慢 我想了想 能不能先查询父机构 再点击父机构再去根据父机构查询子机构 思路倒是出来了 前端vue不知道怎么处理 tree树形菜单 求指点

springboot +mybatis分页问题,其中一种情况分页结果不对

情况如下: ``` PageHelper.startPage(currentPage, pageSize); List<CardInfosVO> cardInfosList = cardService.getInfosByParam(map); ``` 然后根据不同的业务场景又对cardInfosList进行了不同的组装,第一种情况是所有的结果集,第二种情况是删除了部分数据,最后 ``` PageInfo<CardInfosVO> pageInfo = new PageInfo<CardInfosVO>(cardInfosList); ``` 最终的结果就是第一种情况的分页正确,第二种情况的分页cardInfosList的结果集是对的,但是分页的总条数和分页的页数不对。 哪位高人给指点下。

mybaits参数是英文可以查询数据 ,输入中文查询不出来,求大神帮忙

用的是mysql数据库 控制台打印出来的sql 放到数据库中可以查询出来数据, 参数传到mybaits 中是中文的 为什么查询不出来啊 求大神帮忙 <!--查询数据表数据 --> <select id="getSiteList" parameterType="hashmap" resultType="hashmap"> select * from tb_msg_content where 1=1 <if test="title !=null and title !='' "> and status='${title}' </if> limit ${(page-1)*pagesize},${pagesize} </select> 控制台能打印中文参数 并且已经传到mybaits中 将控制台的传入中文的sql 放到mysql中可以查询数据 但mybaits返回为空

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

程序员请照顾好自己,周末病魔差点一套带走我。

程序员在一个周末的时间,得了重病,差点当场去世,还好及时挽救回来了。

技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...

上班一个月,后悔当初着急入职的选择了

最近有个老铁,告诉我说,上班一个月,后悔当初着急入职现在公司了。他之前在美图做手机研发,今年美图那边今年也有一波组织优化调整,他是其中一个,在协商离职后,当时捉急找工作上班,因为有房贷供着,不能没有收入来源。所以匆忙选了一家公司,实际上是一个大型外包公司,主要派遣给其他手机厂商做外包项目。**当时承诺待遇还不错,所以就立马入职去上班了。但是后面入职后,发现薪酬待遇这块并不是HR所说那样,那个HR自...

女程序员,为什么比男程序员少???

昨天看到一档综艺节目,讨论了两个话题:(1)中国学生的数学成绩,平均下来看,会比国外好?为什么?(2)男生的数学成绩,平均下来看,会比女生好?为什么?同时,我又联想到了一个技术圈经常讨...

总结了 150 余个神奇网站,你不来瞅瞅吗?

原博客再更新,可能就没了,之后将持续更新本篇博客。

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

外包程序员的幸福生活

今天给你们讲述一个外包程序员的幸福生活。男主是Z哥,不是在外包公司上班的那种,是一名自由职业者,接外包项目自己干。接下来讲的都是真人真事。 先给大家介绍一下男主,Z哥,老程序员,是我十多年前的老同事,技术大牛,当过CTO,也创过业。因为我俩都爱好喝酒、踢球,再加上住的距离不算远,所以一直也断断续续的联系着,我对Z哥的状况也有大概了解。 Z哥几年前创业失败,后来他开始干起了外包,利用自己的技术能...

优雅的替换if-else语句

场景 日常开发,if-else语句写的不少吧??当逻辑分支非常多的时候,if-else套了一层又一层,虽然业务功能倒是实现了,但是看起来是真的很不优雅,尤其是对于我这种有强迫症的程序"猿",看到这么多if-else,脑袋瓜子就嗡嗡的,总想着解锁新姿势:干掉过多的if-else!!!本文将介绍三板斧手段: 优先判断条件,条件不满足的,逻辑及时中断返回; 采用策略模式+工厂模式; 结合注解,锦...

深入剖析Springboot启动原理的底层源码,再也不怕面试官问了!

大家现在应该都对Springboot很熟悉,但是你对他的启动原理了解吗?

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

2020阿里全球数学大赛:3万名高手、4道题、2天2夜未交卷

阿里巴巴全球数学竞赛( Alibaba Global Mathematics Competition)由马云发起,由中国科学技术协会、阿里巴巴基金会、阿里巴巴达摩院共同举办。大赛不设报名门槛,全世界爱好数学的人都可参与,不论是否出身数学专业、是否投身数学研究。 2020年阿里巴巴达摩院邀请北京大学、剑桥大学、浙江大学等高校的顶尖数学教师组建了出题组。中科院院士、美国艺术与科学院院士、北京国际数学...

男生更看重女生的身材脸蛋,还是思想?

往往,我们看不进去大段大段的逻辑。深刻的哲理,往往短而精悍,一阵见血。问:产品经理挺漂亮的,有点心动,但不知道合不合得来。男生更看重女生的身材脸蛋,还是...

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

当HR压你价,说你只值7K,你该怎么回答?

当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...

面试:第十六章:Java中级开发(16k)

HashMap底层实现原理,红黑树,B+树,B树的结构原理 Spring的AOP和IOC是什么?它们常见的使用场景有哪些?Spring事务,事务的属性,传播行为,数据库隔离级别 Spring和SpringMVC,MyBatis以及SpringBoot的注解分别有哪些?SpringMVC的工作原理,SpringBoot框架的优点,MyBatis框架的优点 SpringCould组件有哪些,他们...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

你期望月薪4万,出门右拐,不送,这几个点,你也就是个初级的水平

先来看几个问题通过注解的方式注入依赖对象,介绍一下你知道的几种方式@Autowired和@Resource有何区别说一下@Autowired查找候选者的...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

《Oracle Java SE编程自学与面试指南》最佳学习路线图2020年最新版(进大厂必备)

正确选择比瞎努力更重要!

《Oracle Java SE编程自学与面试指南》最佳学习路线图(2020最新版)

正确选择比瞎努力更重要!

字节跳动面试官竟然问了我JDBC?

轻松等回家通知

面试官:你连SSO都不懂,就别来面试了

大厂竟然要考我SSO,卧槽。

终于,月薪过5万了!

来看几个问题想不想月薪超过5万?想不想进入公司架构组?想不想成为项目组的负责人?想不想成为spring的高手,超越99%的对手?那么本文内容是你必须要掌握的。本文主要详解bean的生命...

自从喜欢上了B站这12个UP主,我越来越觉得自己是个废柴了!

不怕告诉你,我自从喜欢上了这12个UP主,哔哩哔哩成为了我手机上最耗电的软件,几乎每天都会看,可是吧,看的越多,我就越觉得自己是个废柴,唉,老天不公啊,不信你看看…… 间接性踌躇满志,持续性混吃等死,都是因为你们……但是,自己的学习力在慢慢变强,这是不容忽视的,推荐给你们! 都说B站是个宝,可是有人不会挖啊,没事,今天咱挖好的送你一箩筐,首先啊,我在B站上最喜欢看这个家伙的视频了,为啥 ,咱撇...

立即提问
相关内容推荐