Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bigsys
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
bigsys
Commits
81d68553
Commit
81d68553
authored
Aug 16, 2017
by
fangzhipeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
实现shiro权限共享
parent
b600d774
Changes
20
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
822 additions
and
2 deletions
+822
-2
bigsys-auth/pom.xml
bigsys-auth/pom.xml
+17
-0
bigsys-dubbo/pom.xml
bigsys-dubbo/pom.xml
+17
-0
bigsys-redis/pom.xml
bigsys-redis/pom.xml
+17
-0
bigsys-redis/src/main/java/com/bigsys/redis/service/Event.java
...s-redis/src/main/java/com/bigsys/redis/service/Event.java
+12
-0
bigsys-redis/src/main/java/com/bigsys/redis/service/RedisDb.java
...redis/src/main/java/com/bigsys/redis/service/RedisDb.java
+55
-0
bigsys-shiro/pom.xml
bigsys-shiro/pom.xml
+23
-0
bigsys-shiro/src/main/java/com/bigsys/shiro/authcache/RedisCache.java
.../src/main/java/com/bigsys/shiro/authcache/RedisCache.java
+266
-0
bigsys-shiro/src/main/java/com/bigsys/shiro/authcache/RedisCacheManager.java
...in/java/com/bigsys/shiro/authcache/RedisCacheManager.java
+67
-0
bigsys-shiro/src/main/java/com/bigsys/shiro/session/SessionManager.java
...rc/main/java/com/bigsys/shiro/session/SessionManager.java
+83
-0
bigsys-shiro/src/main/resources/bigsys-shiro.xml
bigsys-shiro/src/main/resources/bigsys-shiro.xml
+22
-2
bigsys-spring/pom.xml
bigsys-spring/pom.xml
+17
-0
bigsys-user/pom.xml
bigsys-user/pom.xml
+17
-0
bigsys-webdemo/pom.xml
bigsys-webdemo/pom.xml
+17
-0
bigsys-webdemo2/pom.xml
bigsys-webdemo2/pom.xml
+47
-0
bigsys-webdemo2/src/main/java/com/bigsys/webdemo/TestController.java
...emo2/src/main/java/com/bigsys/webdemo/TestController.java
+25
-0
bigsys-webdemo2/src/main/resources/applicationContext.xml
bigsys-webdemo2/src/main/resources/applicationContext.xml
+15
-0
bigsys-webdemo2/src/main/resources/spring-mvc.xml
bigsys-webdemo2/src/main/resources/spring-mvc.xml
+38
-0
bigsys-webdemo2/src/main/webapp/WEB-INF/web.xml
bigsys-webdemo2/src/main/webapp/WEB-INF/web.xml
+61
-0
bigsys-webdemo2/src/main/webapp/index.jsp
bigsys-webdemo2/src/main/webapp/index.jsp
+5
-0
pom.xml
pom.xml
+1
-0
No files found.
bigsys-auth/pom.xml
View file @
81d68553
...
...
@@ -13,6 +13,7 @@
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<project.build.jdk>
1.8
</project.build.jdk>
<!-- 设置 Spring 的版本 -->
<spring.vesion>
4.3.10.RELEASE
</spring.vesion>
...
...
@@ -67,4 +68,20 @@
<build>
<finalName>
auth
</finalName>
</build>
<build>
<plugins>
<!--Maven编译插件 配置 -->
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-compiler-plugin
</artifactId>
<version>
${plugin.maven-compiler}
</version>
<configuration>
<source>
${project.build.jdk}
</source>
<target>
${project.build.jdk}
</target>
<encoding>
${project.build.sourceEncoding}
</encoding>
</configuration>
</plugin>
</plugins>
</build>
</project>
bigsys-dubbo/pom.xml
View file @
81d68553
...
...
@@ -15,6 +15,7 @@
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<project.build.jdk>
1.8
</project.build.jdk>
</properties>
<dependencies>
...
...
@@ -48,4 +49,20 @@
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<!--Maven编译插件 配置 -->
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-compiler-plugin
</artifactId>
<version>
${plugin.maven-compiler}
</version>
<configuration>
<source>
${project.build.jdk}
</source>
<target>
${project.build.jdk}
</target>
<encoding>
${project.build.sourceEncoding}
</encoding>
</configuration>
</plugin>
</plugins>
</build>
</project>
bigsys-redis/pom.xml
View file @
81d68553
...
...
@@ -16,6 +16,7 @@
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<project.build.jdk>
1.8
</project.build.jdk>
<!-- 设置 Spring 的版本 -->
<spring.vesion>
4.3.10.RELEASE
</spring.vesion>
</properties>
...
...
@@ -38,4 +39,20 @@
</dependencies>
<build>
<plugins>
<!--Maven编译插件 配置 -->
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-compiler-plugin
</artifactId>
<version>
${plugin.maven-compiler}
</version>
<configuration>
<source>
${project.build.jdk}
</source>
<target>
${project.build.jdk}
</target>
<encoding>
${project.build.sourceEncoding}
</encoding>
</configuration>
</plugin>
</plugins>
</build>
</project>
bigsys-redis/src/main/java/com/bigsys/redis/service/Event.java
0 → 100644
View file @
81d68553
package
com
.
bigsys
.
redis
.
service
;
import
redis.clients.jedis.Jedis
;
/**
* Created by fangzhipeng on 2017/8/15.
*/
public
interface
Event
{
void
excuate
(
Jedis
jedis
);
}
bigsys-redis/src/main/java/com/bigsys/redis/service/RedisDb.java
0 → 100644
View file @
81d68553
package
com
.
bigsys
.
redis
.
service
;
import
redis.clients.jedis.Jedis
;
import
redis.clients.jedis.JedisPool
;
import
javax.swing.*
;
/**
* Created by fangzhipeng on 2017/8/15.
*/
public
class
RedisDb
{
private
static
JedisPool
jedisPool
;
static
{
jedisPool
=
new
JedisPool
(
"127.0.0.1"
);
}
public
static
Jedis
getJedis
()
{
return
jedisPool
.
getResource
();
}
public
static
void
setObject
(
final
byte
[]
key
,
final
byte
[]
object
)
{
deal
((
jedis
)
->
{
jedis
.
set
(
key
,
object
);});
}
public
static
void
delString
(
String
key
)
{
deal
(
jedis
->
jedis
.
del
(
key
));
}
public
static
byte
[]
getObject
(
byte
[]
key
)
{
Result
result
=
new
Result
();
deal
(
jedis
->
{
result
.
setObject
(
jedis
.
get
(
key
));});
return
(
byte
[])
result
.
getObject
();
}
private
static
void
deal
(
Event
event
)
{
Jedis
jedis
=
jedisPool
.
getResource
();
event
.
excuate
(
jedis
);
jedis
.
close
();
}
static
class
Result
{
Object
object
;
public
Object
getObject
()
{
return
object
;
}
public
void
setObject
(
Object
object
)
{
this
.
object
=
object
;
}
}
}
bigsys-shiro/pom.xml
View file @
81d68553
...
...
@@ -15,6 +15,7 @@
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<project.build.jdk>
1.8
</project.build.jdk>
<shiro.version>
1.4.0
</shiro.version>
</properties>
...
...
@@ -27,6 +28,12 @@
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
com.bigsys
</groupId>
<artifactId>
bigsys-redis
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
<dependency>
<groupId>
org.apache.shiro
</groupId>
<artifactId>
shiro-core
</artifactId>
...
...
@@ -55,4 +62,20 @@
</dependency>
</dependencies>
<build>
<plugins>
<!--Maven编译插件 配置 -->
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-compiler-plugin
</artifactId>
<version>
${plugin.maven-compiler}
</version>
<configuration>
<source>
${project.build.jdk}
</source>
<target>
${project.build.jdk}
</target>
<encoding>
${project.build.sourceEncoding}
</encoding>
</configuration>
</plugin>
</plugins>
</build>
</project>
bigsys-shiro/src/main/java/com/bigsys/shiro/authcache/RedisCache.java
0 → 100644
View file @
81d68553
package
com
.
bigsys
.
shiro
.
authcache
;
import
org.apache.shiro.cache.Cache
;
import
org.apache.shiro.cache.CacheException
;
import
org.apache.shiro.subject.PrincipalCollection
;
import
org.apache.shiro.util.CollectionUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
redis.clients.jedis.Jedis
;
import
java.io.*
;
import
java.util.*
;
/**
* Created by fangzhipeng on 2017/8/16.
*/
public
class
RedisCache
<
K
,
V
>
implements
Cache
<
K
,
V
>
{
private
Logger
logger
=
LoggerFactory
.
getLogger
(
this
.
getClass
());
/**
* The wrapped Jedis instance.
*/
private
Jedis
cache
;
/**
* The Redis key prefix for the sessions
*/
private
String
keyPrefix
=
"shiro_session:"
;
/**
* Returns the Redis session keys
* prefix.
* @return The prefix
*/
public
String
getKeyPrefix
()
{
return
keyPrefix
;
}
/**
* Sets the Redis sessions key
* prefix.
* @param keyPrefix The prefix
*/
public
void
setKeyPrefix
(
String
keyPrefix
)
{
this
.
keyPrefix
=
keyPrefix
;
}
/**
* 通过一个JedisManager实例构造RedisCache
*/
public
RedisCache
(
Jedis
cache
)
{
if
(
cache
==
null
)
{
throw
new
IllegalArgumentException
(
"Cache argument cannot be null."
);
}
this
.
cache
=
cache
;
}
/**
* Constructs a cache instance with the specified
* Redis manager and using a custom key prefix.
* @param cache The cache manager instance
* @param prefix The Redis key prefix
*/
public
RedisCache
(
Jedis
cache
,
String
prefix
)
{
this
(
cache
);
// set the prefix
this
.
keyPrefix
=
prefix
;
}
/**
* 获得byte[]型的key
* @param key
* @return
*/
private
byte
[]
getByteKey
(
K
key
)
{
if
(
key
instanceof
String
)
{
String
preKey
=
this
.
keyPrefix
+
key
;
return
preKey
.
getBytes
();
}
else
if
(
key
instanceof
PrincipalCollection
){
String
preKey
=
this
.
keyPrefix
+
key
.
toString
();
return
preKey
.
getBytes
();
}
return
new
byte
[
1
];
}
@Override
public
V
get
(
K
key
)
throws
CacheException
{
logger
.
debug
(
"根据key从Redis中获取对象 key ["
+
key
+
"]"
);
try
{
if
(
key
==
null
)
{
return
null
;
}
else
{
byte
[]
rawValue
=
cache
.
get
(
getByteKey
(
key
));
@SuppressWarnings
(
"unchecked"
)
V
value
=
(
V
)
byteToObject
(
rawValue
);
return
value
;
}
}
catch
(
Throwable
t
)
{
t
.
printStackTrace
();
return
null
;
}
}
public
String
getStr
(
String
key
)
throws
CacheException
{
logger
.
debug
(
"根据key从Redis中获取对象 key ["
+
key
+
"]"
);
try
{
if
(
key
==
null
)
{
return
null
;
}
else
{
return
cache
.
get
(
key
);
}
}
catch
(
Throwable
t
)
{
throw
new
CacheException
(
t
);
}
}
@Override
public
V
put
(
K
key
,
V
value
)
throws
CacheException
{
logger
.
debug
(
"根据key从存储 key ["
+
key
+
"]"
);
try
{
cache
.
set
(
getByteKey
(
key
),
objectToByte
(
value
));
return
value
;
}
catch
(
Throwable
t
)
{
throw
new
CacheException
(
t
);
}
}
public
String
putStr
(
String
key
,
String
value
)
throws
CacheException
{
logger
.
debug
(
"根据key从存储 key ["
+
key
+
"]"
);
try
{
cache
.
set
(
key
,
value
);
return
value
;
}
catch
(
Throwable
t
)
{
throw
new
CacheException
(
t
);
}
}
// public String put(String key,String value, int expire) throws CacheException {
// logger.debug("根据key从存储 key [" + key + "]");
// try {
// cache.set(key, value, expire);
// cache.set
// return value;
// } catch (Throwable t) {
// throw new CacheException(t);
// }
// }
public
String
removeString
(
String
key
)
throws
CacheException
{
logger
.
debug
(
"从redis中删除 key ["
+
key
+
"]"
);
try
{
String
previous
=
cache
.
get
(
key
);
cache
.
del
(
key
);
return
previous
;
}
catch
(
Throwable
t
)
{
throw
new
CacheException
(
t
);
}
}
@Override
public
V
remove
(
K
key
)
throws
CacheException
{
logger
.
debug
(
"从redis中删除 key ["
+
key
+
"]"
);
try
{
V
previous
=
get
(
key
);
cache
.
del
(
getByteKey
(
key
));
return
previous
;
}
catch
(
Throwable
t
)
{
throw
new
CacheException
(
t
);
}
}
@Override
public
void
clear
()
throws
CacheException
{
logger
.
debug
(
"从redis中删除所有元素"
);
try
{
cache
.
flushDB
();
}
catch
(
Throwable
t
)
{
throw
new
CacheException
(
t
);
}
}
@Override
public
int
size
()
{
try
{
Long
longSize
=
new
Long
(
cache
.
dbSize
());
return
longSize
.
intValue
();
}
catch
(
Throwable
t
)
{
throw
new
CacheException
(
t
);
}
}
@SuppressWarnings
(
"unchecked"
)
@Override
public
Set
<
K
>
keys
()
{
try
{
Set
<
String
>
keys
=
cache
.
keys
(
this
.
keyPrefix
+
"*"
);
if
(
CollectionUtils
.
isEmpty
(
keys
))
{
return
Collections
.
emptySet
();
}
else
{
Set
<
K
>
newKeys
=
new
HashSet
<
K
>();
for
(
String
key
:
keys
)
{
newKeys
.
add
((
K
)
key
);
}
return
newKeys
;
}
}
catch
(
Throwable
t
)
{
throw
new
CacheException
(
t
);
}
}
@Override
public
Collection
<
V
>
values
()
{
try
{
Set
<
String
>
keys
=
cache
.
keys
(
this
.
keyPrefix
+
"*"
);
if
(!
CollectionUtils
.
isEmpty
(
keys
))
{
List
<
V
>
values
=
new
ArrayList
<
V
>(
keys
.
size
());
for
(
String
key
:
keys
)
{
@SuppressWarnings
(
"unchecked"
)
V
value
=
get
((
K
)
key
);
if
(
value
!=
null
)
{
values
.
add
(
value
);
}
}
return
Collections
.
unmodifiableList
(
values
);
}
else
{
return
Collections
.
emptyList
();
}
}
catch
(
Throwable
t
)
{
throw
new
CacheException
(
t
);
}
}
// 把session对象转化为byte保存到redis中
public
byte
[]
objectToByte
(
Object
session
){
ByteArrayOutputStream
bo
=
new
ByteArrayOutputStream
();
byte
[]
bytes
=
null
;
try
{
ObjectOutputStream
oo
=
new
ObjectOutputStream
(
bo
);
oo
.
writeObject
(
session
);
bytes
=
bo
.
toByteArray
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
return
bytes
;
}
// 把byte还原为session
public
Object
byteToObject
(
byte
[]
bytes
){
ByteArrayInputStream
bi
=
new
ByteArrayInputStream
(
bytes
);
ObjectInputStream
in
;
Object
session
=
null
;
try
{
in
=
new
ObjectInputStream
(
bi
);
session
=
in
.
readObject
();
}
catch
(
ClassNotFoundException
e
)
{
e
.
printStackTrace
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
return
session
;
}
}
bigsys-shiro/src/main/java/com/bigsys/shiro/authcache/RedisCacheManager.java
0 → 100644
View file @
81d68553
package
com
.
bigsys
.
shiro
.
authcache
;
import
com.bigsys.redis.service.RedisDb
;
import
org.apache.shiro.cache.Cache
;
import
org.apache.shiro.cache.CacheException
;
import
org.apache.shiro.cache.CacheManager
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
redis.clients.jedis.Jedis
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.ConcurrentMap
;
/**
* Created by fangzhipeng on 2017/8/16.
*/
public
class
RedisCacheManager
implements
CacheManager
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
RedisCacheManager
.
class
);
// fast lookup by name map
private
final
ConcurrentMap
<
String
,
Cache
>
caches
=
new
ConcurrentHashMap
<
String
,
Cache
>();
private
Jedis
jedis
=
RedisDb
.
getJedis
();
/**
* The Redis key prefix for caches
*/
private
String
keyPrefix
=
"shiro_redis_cache:"
;
/**
* Returns the Redis session keys
* prefix.
* @return The prefix
*/
public
String
getKeyPrefix
()
{
return
keyPrefix
;
}
/**
* Sets the Redis sessions key
* prefix.
* @param keyPrefix The prefix
*/
public
void
setKeyPrefix
(
String
keyPrefix
)
{
this
.
keyPrefix
=
keyPrefix
;
}
@Override
public
<
K
,
V
>
Cache
<
K
,
V
>
getCache
(
String
name
)
throws
CacheException
{
logger
.
debug
(
"获取名称为: "
+
name
+
" 的RedisCache实例"
);
Cache
c
=
caches
.
get
(
name
);
if
(
c
==
null
)
{
// create a new cache instance
c
=
new
RedisCache
<
K
,
V
>(
jedis
,
keyPrefix
);
// add it to the cache collection
caches
.
put
(
name
,
c
);
}
return
c
;
}
}
bigsys-shiro/src/main/java/com/bigsys/shiro/session/SessionManager.java
0 → 100644
View file @
81d68553
package
com
.
bigsys
.
shiro
.
session
;
import
com.bigsys.redis.service.RedisDb
;
import
org.apache.shiro.session.Session
;
import
org.apache.shiro.session.mgt.SimpleSession
;
import
org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO
;
import
java.io.*
;
/**
* Created by fangzhipeng on 2017/8/15.
*/
public
class
SessionManager
extends
EnterpriseCacheSessionDAO
{
// 创建session,保存到数据库
@Override
protected
Serializable
doCreate
(
Session
session
)
{
Serializable
sessionId
=
super
.
doCreate
(
session
);
RedisDb
.
setObject
(
sessionId
.
toString
().
getBytes
(),
sessionToByte
(
session
));
return
sessionId
;
}
// 获取session
@Override
protected
Session
doReadSession
(
Serializable
sessionId
)
{
// 先从缓存中获取session,如果没有再去数据库中获取
// Session session = super.doReadSession(sessionId);
Session
session
=
null
;
if
(
session
==
null
){
byte
[]
bytes
=
RedisDb
.
getObject
(
sessionId
.
toString
().
getBytes
());
if
(
bytes
!=
null
&&
bytes
.
length
>
0
){
session
=
byteToSession
(
bytes
);
}
}
return
session
;
}
// 更新session的最后一次访问时间
@Override
protected
void
doUpdate
(
Session
session
)
{
super
.
doUpdate
(
session
);
RedisDb
.
setObject
(
session
.
getId
().
toString
().
getBytes
(),
sessionToByte
(
session
));
}
// 删除session
@Override
protected
void
doDelete
(
Session
session
)
{
super
.
doDelete
(
session
);
RedisDb
.
delString
(
session
.
getId
()
+
""
);
}
// 把session对象转化为byte保存到redis中
public
byte
[]
sessionToByte
(
Session
session
){
ByteArrayOutputStream
bo
=
new
ByteArrayOutputStream
();
byte
[]
bytes
=
null
;
try
{
ObjectOutputStream
oo
=
new
ObjectOutputStream
(
bo
);
oo
.
writeObject
(
session
);
bytes
=
bo
.
toByteArray
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
return
bytes
;
}
// 把byte还原为session
public
Session
byteToSession
(
byte
[]
bytes
){
ByteArrayInputStream
bi
=
new
ByteArrayInputStream
(
bytes
);
ObjectInputStream
in
;
SimpleSession
session
=
null
;
try
{
in
=
new
ObjectInputStream
(
bi
);
session
=
(
SimpleSession
)
in
.
readObject
();
}
catch
(
ClassNotFoundException
e
)
{
e
.
printStackTrace
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
return
session
;
}
}
bigsys-shiro/src/main/resources/bigsys-shiro.xml
View file @
81d68553
...
...
@@ -19,16 +19,36 @@
<bean
id=
"authc"
class=
"com.bigsys.shiro.filter.LoginFilter"
>
</bean>
<bean
id=
"sessionDAO"
class=
"com.bigsys.shiro.session.SessionManager"
></bean>
<bean
id=
"sessionIdCookie"
class=
"org.apache.shiro.web.servlet.SimpleCookie"
>
<constructor-arg
value=
"bigsys-cookie"
/>
<property
name=
"httpOnly"
value=
"true"
/>
<property
name=
"maxAge"
value=
"-1"
/>
<property
name=
"path"
value=
"/"
/>
<!-- 配置存储Session Cookie的domain为 二级域名 -->
<property
name=
"domain"
value=
".bigsys.com"
/>
</bean>
<bean
id=
"sessionManager"
class=
"org.apache.shiro.web.session.mgt.DefaultWebSessionManager"
>
<property
name=
"sessionDAO"
ref=
"sessionDAO"
></property>
<property
name=
"sessionIdCookie"
ref=
"sessionIdCookie"
></property>
</bean>
<bean
id=
"cacheManager"
class=
"com.bigsys.shiro.authcache.RedisCacheManager"
/>
<!-- 安全管理器 -->
<bean
id=
"securityManager"
class=
"org.apache.shiro.web.mgt.DefaultWebSecurityManager"
>
<property
name=
"realm"
ref=
"userRealm"
/>
<property
name=
"sessionManager"
ref=
"sessionManager"
></property>
<property
name=
"cacheManager"
ref=
"cacheManager"
/>
</bean>
<bean
id=
"shiroFilter"
class=
"org.apache.shiro.spring.web.ShiroFilterFactoryBean"
>
<property
name=
"securityManager"
ref=
"securityManager"
/>
<property
name=
"loginUrl"
value=
"/static/login.html"
/>
<property
name=
"successUrl"
value=
"/
hello
"
/>
<property
name=
"unauthorizedUrl"
value=
"/
static/login.html
"
/>
<property
name=
"successUrl"
value=
"/"
/>
<property
name=
"unauthorizedUrl"
value=
"/"
/>
<property
name=
"filterChainDefinitions"
>
<value>
/home* = anon
...
...
bigsys-spring/pom.xml
View file @
81d68553
...
...
@@ -18,6 +18,7 @@
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<project.build.jdk>
1.8
</project.build.jdk>
<!-- 设置 Spring 的版本 -->
<spring.vesion>
4.3.10.RELEASE
</spring.vesion>
...
...
@@ -117,4 +118,20 @@
<version>
${spring.vesion}
</version>
</dependency>
</dependencies>
<build>
<plugins>
<!--Maven编译插件 配置 -->
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-compiler-plugin
</artifactId>
<version>
${plugin.maven-compiler}
</version>
<configuration>
<source>
${project.build.jdk}
</source>
<target>
${project.build.jdk}
</target>
<encoding>
${project.build.sourceEncoding}
</encoding>
</configuration>
</plugin>
</plugins>
</build>
</project>
bigsys-user/pom.xml
View file @
81d68553
...
...
@@ -16,6 +16,7 @@
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<project.build.jdk>
1.8
</project.build.jdk>
<!-- 设置 Spring 的版本 -->
<spring.vesion>
4.3.10.RELEASE
</spring.vesion>
</properties>
...
...
@@ -30,4 +31,20 @@
</dependencies>
<build>
<plugins>
<!--Maven编译插件 配置 -->
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-compiler-plugin
</artifactId>
<version>
${plugin.maven-compiler}
</version>
<configuration>
<source>
${project.build.jdk}
</source>
<target>
${project.build.jdk}
</target>
<encoding>
${project.build.sourceEncoding}
</encoding>
</configuration>
</plugin>
</plugins>
</build>
</project>
bigsys-webdemo/pom.xml
View file @
81d68553
...
...
@@ -11,6 +11,10 @@
<name>
bigsys-webdemo Maven Webapp
</name>
<url>
http://maven.apache.org
</url>
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<project.build.jdk>
1.8
</project.build.jdk>
</properties>
<dependencies>
<dependency>
...
...
@@ -26,5 +30,18 @@
</dependencies>
<build>
<finalName>
bigsys-webdemo
</finalName>
<plugins>
<!--Maven编译插件 配置 -->
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-compiler-plugin
</artifactId>
<version>
${plugin.maven-compiler}
</version>
<configuration>
<source>
${project.build.jdk}
</source>
<target>
${project.build.jdk}
</target>
<encoding>
${project.build.sourceEncoding}
</encoding>
</configuration>
</plugin>
</plugins>
</build>
</project>
bigsys-webdemo2/pom.xml
0 → 100644
View file @
81d68553
<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/maven-v4_0_0.xsd"
>
<parent>
<artifactId>
bigsys
</artifactId>
<groupId>
com.bigsys
</groupId>
<version>
1.0-SNAPSHOT
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
bigsys-webdemo2
</artifactId>
<packaging>
war
</packaging>
<name>
bigsys-webdemo Maven Webapp
</name>
<url>
http://maven.apache.org
</url>
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<project.build.jdk>
1.8
</project.build.jdk>
</properties>
<dependencies>
<dependency>
<groupId>
com.bigsys
</groupId>
<artifactId>
bigsys-spring
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
<dependency>
<groupId>
com.bigsys
</groupId>
<artifactId>
bigsys-shiro
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
</dependencies>
<build>
<finalName>
bigsys-webdemo2
</finalName>
<plugins>
<!--Maven编译插件 配置 -->
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-compiler-plugin
</artifactId>
<version>
${plugin.maven-compiler}
</version>
<configuration>
<source>
${project.build.jdk}
</source>
<target>
${project.build.jdk}
</target>
<encoding>
${project.build.sourceEncoding}
</encoding>
</configuration>
</plugin>
</plugins>
</build>
</project>
bigsys-webdemo2/src/main/java/com/bigsys/webdemo/TestController.java
0 → 100644
View file @
81d68553
package
com
.
bigsys
.
webdemo
;
import
org.apache.shiro.web.servlet.ShiroFilter
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
javax.annotation.Resource
;
/**
* Created by fangzhipeng on 2017/8/15.
*/
@Controller
public
class
TestController
{
@RequestMapping
(
value
=
"/hello"
)
@ResponseBody
public
String
hello
()
{
System
.
out
.
println
(
"hit"
);
return
"hello world"
;
}
}
bigsys-webdemo2/src/main/resources/applicationContext.xml
0 → 100644
View file @
81d68553
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns=
"http://www.springframework.org/schema/beans"
xmlns:context=
"http://www.springframework.org/schema/context"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc=
"http://www.springframework.org/schema/mvc"
xsi:schemaLocation=
"http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd"
>
<import
resource=
"spring-mvc.xml"
/>
<!--<import resource="classpath*:bigsys-shiro.xml"/>-->
</beans>
\ No newline at end of file
bigsys-webdemo2/src/main/resources/spring-mvc.xml
0 → 100644
View file @
81d68553
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns=
"http://www.springframework.org/schema/beans"
xmlns:context=
"http://www.springframework.org/schema/context"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc=
"http://www.springframework.org/schema/mvc"
xsi:schemaLocation=
"http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd"
>
<context:component-scan
base-package=
"com.bigsys.webdemo"
/>
<mvc:annotation-driven
/>
<bean
class=
"org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"
>
<property
name=
"urlMap"
>
<map>
<entry
key=
"/static/**"
value=
"myResourceHandler"
/>
</map>
</property>
<property
name=
"order"
value=
"100000"
/>
</bean>
<bean
id=
"myResourceHandler"
name=
"myResourceHandler"
class=
"org.springframework.web.servlet.resource.ResourceHttpRequestHandler"
>
<property
name=
"locations"
value=
"classpath:/static/"
/>
<property
name=
"supportedMethods"
>
<list>
<value>
GET
</value>
<value>
HEAD
</value>
<value>
POST
</value>
</list>
</property>
</bean>
</beans>
\ No newline at end of file
bigsys-webdemo2/src/main/webapp/WEB-INF/web.xml
0 → 100644
View file @
81d68553
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>
Archetype Created Web Application
</display-name>
<servlet>
<servlet-name>
dispatcher
</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<init-param>
<param-name>
contextConfigLocation
</param-name>
<param-value>
classpath:applicationContext.xml
classpath*:bigsys-*.xml
</param-value>
</init-param>
<load-on-startup>
0
</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>
dispatcher
</servlet-name>
<url-pattern>
/
</url-pattern>
</servlet-mapping>
<filter>
<filter-name>
encodingFilter
</filter-name>
<filter-class>
org.springframework.web.filter.CharacterEncodingFilter
</filter-class>
<init-param>
<param-name>
encoding
</param-name>
<param-value>
UTF-8
</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>
encodingFilter
</filter-name>
<url-pattern>
/*
</url-pattern>
</filter-mapping>
<!-- 配置Shiro过滤器,先让Shiro过滤系统接收到的请求 -->
<!-- 这里filter-name必须对应applicationContext.xml中定义的<bean id="shiroFilter"/> -->
<!-- 使用[/*]匹配所有请求,保证所有的可控请求都经过Shiro的过滤 -->
<!-- 通常会将此filter-mapping放置到最前面(即其他filter-mapping前面),以保证它是过滤器链中第一个起作用的 -->
<filter>
<filter-name>
shiroFilter
</filter-name>
<filter-class>
org.springframework.web.filter.DelegatingFilterProxy
</filter-class>
<init-param>
<!-- 该值缺省为false,表示生命周期由SpringApplicationContext管理,设置为true则表示由servlet container管理 -->
<param-name>
targetFilterLifecycle
</param-name>
<param-value>
true
</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>
shiroFilter
</filter-name>
<url-pattern>
/*
</url-pattern>
</filter-mapping>
</web-app>
bigsys-webdemo2/src/main/webapp/index.jsp
0 → 100644
View file @
81d68553
<html>
<body>
<h2>
Hello World!
</h2>
</body>
</html>
pom.xml
View file @
81d68553
...
...
@@ -16,6 +16,7 @@
<module>
bigsys-spring
</module>
<module>
bigsys-dubbo
</module>
<module>
bigsys-webdemo
</module>
<module>
bigsys-webdemo2
</module>
</modules>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment