Skip to content

Commit

Permalink
解决h2升级到2.x后user变为关键字导致sql执行失败的问题,解决spring boot2.7之后,spring.datasource…
Browse files Browse the repository at this point in the history
….schema改为spring.sql.init.schema-locations的问题。
  • Loading branch information
abel533 committed Sep 15, 2022
1 parent 1222259 commit d6c04a0
Show file tree
Hide file tree
Showing 7 changed files with 762 additions and 381 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageRowBounds;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
Expand Down Expand Up @@ -55,6 +56,13 @@ public void run(String... args) throws Exception {
for (User user : users) {
System.out.println("Name: " + user.getName());
}

PageRowBounds rowBounds = new PageRowBounds(3, 5);
users = userMapper.findAll(rowBounds);
System.out.println("Total: " + rowBounds.getTotal());
for (User user : users) {
System.out.println("Name: " + user.getName());
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,17 @@

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.session.RowBounds;
import tk.mybatis.pagehelper.domain.User;

import java.util.List;

@Mapper
public interface UserMapper {

@Select("select * from user")
@Select("select * from sys_user")
List<User> findAll();

List<User> findAll(RowBounds rowBounds);

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
spring.datasource.schema=import.sql
spring.sql.init.schema-locations=import.sql
debug=true
logging.level.root=WARN
logging.level.tk.mybatis.pagehelper.mapper=TRACE
#pagehelper.
Expand All @@ -30,4 +31,4 @@ pagehelper.closeConn=true
#\u6D4B\u8BD5\u5C5E\u6027\u6CE8\u5165
pagehelper.hello=\u4F60\u597D
pagehelper.nihao=Hello
pagehelper.offset-as-page-num=false
pagehelper.offset-as-page-num=true

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
spring.datasource.schema=import.sql
spring.sql.init.schema-locations=import.sql
mybatis.config-location=mybatis-config.xml
logging.level.root=WARN
logging.level.tk.mybatis.pagehelper.mapper=TRACE
Loading

0 comments on commit d6c04a0

Please sign in to comment.