Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MaxKey单点登录官方(MaxKeyTop)
Mybatis Jpa Extra
提交
209d7b7e
M
Mybatis Jpa Extra
项目概览
MaxKey单点登录官方(MaxKeyTop)
/
Mybatis Jpa Extra
10 个月 前同步成功
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
Mybatis Jpa Extra
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
209d7b7e
编写于
4月 24, 2022
作者:
M
MaxKey
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
WebContext -> JpaWebContext
上级
aa2b0548
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
55 addition
and
15 deletion
+55
-15
mybatis-jpa-extra-core/src/main/java/org/apache/mybatis/jpa/persistence/JpaBaseService.java
...va/org/apache/mybatis/jpa/persistence/JpaBaseService.java
+2
-2
mybatis-jpa-extra-core/src/main/java/org/apache/mybatis/jpa/util/JpaWebContext.java
.../main/java/org/apache/mybatis/jpa/util/JpaWebContext.java
+43
-3
mybatis-jpa-extra-core/src/test/java/org/apache/mybatis/jpa/test/MyBatisTestRunner.java
...t/java/org/apache/mybatis/jpa/test/MyBatisTestRunner.java
+3
-3
mybatis-jpa-extra-spring-boot-starter/src/test/java/org/apache/mybatis/jpa/test/MybatisJpaApplication.java
...va/org/apache/mybatis/jpa/test/MybatisJpaApplication.java
+2
-2
mybatis-jpa-extra-spring-boot-starter/src/test/java/org/apache/mybatis/jpa/test/MybatisJpaApplicationTest.java
...rg/apache/mybatis/jpa/test/MybatisJpaApplicationTest.java
+2
-2
mybatis-jpa-extra-test/src/test/java/org/apache/mybatis/jpa/test/MyBatisTestRunner.java
...t/java/org/apache/mybatis/jpa/test/MyBatisTestRunner.java
+3
-3
未找到文件。
mybatis-jpa-extra-core/src/main/java/org/apache/mybatis/jpa/persistence/JpaBaseService.java
浏览文件 @
209d7b7e
...
...
@@ -28,7 +28,7 @@ import org.apache.mybatis.jpa.PageResultsSqlCache;
import
org.apache.mybatis.jpa.util.BeanUtil
;
import
org.apache.mybatis.jpa.util.InstanceUtil
;
import
org.apache.mybatis.jpa.util.StringUtils
;
import
org.apache.mybatis.jpa.util.WebContext
;
import
org.apache.mybatis.jpa.util.
Jpa
WebContext
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.github.benmanes.caffeine.cache.Cache
;
...
...
@@ -113,7 +113,7 @@ public class JpaBaseService <T extends JpaBaseEntity> {
if
(
mapper
==
null
)
{
String
mapperClassBean
=
mapperClass
.
toLowerCase
().
charAt
(
0
)
+
mapperClass
.
substring
(
1
);
_logger
.
info
(
"mapperClass Bean is {}"
,
mapperClassBean
);
mapper
=
(
IJpaBaseMapper
<
T
>)
WebContext
.
getBean
(
mapperClassBean
);
mapper
=
(
IJpaBaseMapper
<
T
>)
Jpa
WebContext
.
getBean
(
mapperClassBean
);
}
}
catch
(
Exception
e
)
{
_logger
.
error
(
"getMapper Exception "
,
e
);
...
...
mybatis-jpa-extra-core/src/main/java/org/apache/mybatis/jpa/util/WebContext.java
→
mybatis-jpa-extra-core/src/main/java/org/apache/mybatis/jpa/util/
Jpa
WebContext.java
浏览文件 @
209d7b7e
/*
* Copyright [202
1
] [MaxKey of copyright http://www.maxkey.top]
* Copyright [202
2
] [MaxKey of copyright http://www.maxkey.top]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -19,7 +19,11 @@ package org.apache.mybatis.jpa.util;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpSession
;
import
org.apache.commons.lang.SystemUtils
;
import
org.joda.time.DateTime
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.core.env.StandardEnvironment
;
import
org.springframework.web.context.request.RequestContextHolder
;
import
org.springframework.web.context.request.ServletRequestAttributes
;
import
org.springframework.web.context.support.WebApplicationContextUtils
;
...
...
@@ -32,7 +36,11 @@ import org.springframework.web.context.support.WebApplicationContextUtils;
* @author Crystal.Sea
* @since 1.6
*/
public
final
class
WebContext
{
public
final
class
JpaWebContext
{
private
static
String
VERSION
=
null
;
public
static
StandardEnvironment
properties
;
public
static
ApplicationContext
applicationContext
=
null
;
...
...
@@ -119,5 +127,37 @@ public final class WebContext {
public
static
String
getParameter
(
String
name
){
return
getRequest
().
getParameter
(
name
);
}
public
static
String
version
()
{
if
(
VERSION
==
null
)
{
StringBuffer
version
=
new
StringBuffer
(
"---------------------------------------------------------------------------------\n"
);
version
.
append
(
"+ MaxKey \n"
);
version
.
append
(
"+ Single Sign On ( SSO ) \n"
);
version
.
append
(
"+ Version "
);
version
.
append
(
properties
.
getProperty
(
"application.formatted-version"
)+
"\n"
);
version
.
append
(
"+\n"
);
version
.
append
(
String
.
format
(
"+ %sCopyright 2018 - %s https://www.maxkey.top/\n"
,
(
char
)
0xA9
,
new
DateTime
().
getYear
()
));
version
.
append
(
"+ Licensed under the Apache License, Version 2.0 \n"
);
version
.
append
(
"---------------------------------------------------------------------------------\n"
);
version
.
append
(
"+ JAVA \n"
);
version
.
append
(
String
.
format
(
"+ %s java version %s, class %s\n"
,
SystemUtils
.
JAVA_VENDOR
,
SystemUtils
.
JAVA_VERSION
,
SystemUtils
.
JAVA_CLASS_VERSION
));
version
.
append
(
String
.
format
(
"+ %s (build %s, %s)\n"
,
SystemUtils
.
JAVA_VM_NAME
,
SystemUtils
.
JAVA_VM_VERSION
,
SystemUtils
.
JAVA_VM_INFO
));
version
.
append
(
"---------------------------------------------------------------------------------\n"
);
VERSION
=
version
.
toString
();
}
return
VERSION
;
}
}
mybatis-jpa-extra-core/src/test/java/org/apache/mybatis/jpa/test/MyBatisTestRunner.java
浏览文件 @
209d7b7e
...
...
@@ -25,7 +25,7 @@ import java.util.List;
import
org.apache.mybatis.jpa.test.dao.service.StudentsService
;
import
org.apache.mybatis.jpa.test.entity.Students
;
import
org.apache.mybatis.jpa.util.WebContext
;
import
org.apache.mybatis.jpa.util.
Jpa
WebContext
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.slf4j.Logger
;
...
...
@@ -227,7 +227,7 @@ public class MyBatisTestRunner {
_logger
.
info
(
"Application dir "
+
System
.
getProperty
(
"user.dir"
));
context
=
new
ClassPathXmlApplicationContext
(
new
String
[]
{
"spring/applicationContext.xml"
});
WebContext
.
applicationContext
=
context
;
service
=(
StudentsService
)
WebContext
.
getBean
(
"studentsService"
);
Jpa
WebContext
.
applicationContext
=
context
;
service
=(
StudentsService
)
Jpa
WebContext
.
getBean
(
"studentsService"
);
}
}
\ No newline at end of file
mybatis-jpa-extra-spring-boot-starter/src/test/java/org/apache/mybatis/jpa/test/MybatisJpaApplication.java
浏览文件 @
209d7b7e
...
...
@@ -21,7 +21,7 @@ import org.apache.mybatis.jpa.id.SerialGenerator;
import
org.apache.mybatis.jpa.persistence.JpaPageResults
;
import
org.apache.mybatis.jpa.test.dao.service.StudentsService
;
import
org.apache.mybatis.jpa.test.entity.Students
;
import
org.apache.mybatis.jpa.util.WebContext
;
import
org.apache.mybatis.jpa.util.
Jpa
WebContext
;
import
org.mybatis.spring.annotation.MapperScan
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -59,7 +59,7 @@ public class MybatisJpaApplication implements ApplicationRunner{
@Override
public
void
run
(
ApplicationArguments
args
)
throws
Exception
{
WebContext
.
applicationContext
=
applicationContext
;
Jpa
WebContext
.
applicationContext
=
applicationContext
;
_logger
.
info
(
"queryPageResults by mapperId..."
);
Students
student
=
new
Students
();
...
...
mybatis-jpa-extra-spring-boot-starter/src/test/java/org/apache/mybatis/jpa/test/MybatisJpaApplicationTest.java
浏览文件 @
209d7b7e
...
...
@@ -21,7 +21,7 @@ import java.util.ArrayList;
import
java.util.List
;
import
org.apache.mybatis.jpa.test.dao.service.StudentsService
;
import
org.apache.mybatis.jpa.test.entity.Students
;
import
org.apache.mybatis.jpa.util.WebContext
;
import
org.apache.mybatis.jpa.util.
Jpa
WebContext
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
...
...
@@ -50,7 +50,7 @@ public class MybatisJpaApplicationTest{
@Before
public
void
before
()
{
_logger
.
info
(
"---------------- before"
);
WebContext
.
applicationContext
=
applicationContext
;
Jpa
WebContext
.
applicationContext
=
applicationContext
;
}
...
...
mybatis-jpa-extra-test/src/test/java/org/apache/mybatis/jpa/test/MyBatisTestRunner.java
浏览文件 @
209d7b7e
...
...
@@ -24,7 +24,7 @@ import java.util.List;
import
org.apache.mybatis.jpa.test.dao.service.StudentsService
;
import
org.apache.mybatis.jpa.test.entity.Students
;
import
org.apache.mybatis.jpa.util.WebContext
;
import
org.apache.mybatis.jpa.util.
Jpa
WebContext
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.slf4j.Logger
;
...
...
@@ -161,8 +161,8 @@ public class MyBatisTestRunner {
_logger
.
info
(
"Application dir "
+
System
.
getProperty
(
"user.dir"
));
context
=
new
ClassPathXmlApplicationContext
(
new
String
[]
{
"spring/applicationContext.xml"
});
WebContext
.
applicationContext
=
context
;
service
=(
StudentsService
)
WebContext
.
getBean
(
"studentsService"
);
Jpa
WebContext
.
applicationContext
=
context
;
service
=(
StudentsService
)
Jpa
WebContext
.
getBean
(
"studentsService"
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录