Skip to content

Commit 5fa48d3

Browse files
author
梨白
committed
update
1 parent 608d3b5 commit 5fa48d3

73 files changed

Lines changed: 272 additions & 625 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,23 @@ Spring Classic Code
44

55
这是一个spring的demo工程,包含这种框架以及spring-xx 的集成操作.
66

7+
8+
9+
<?xml version="1.0" encoding="UTF-8"?>
10+
<beans xmlns="http://www.springframework.org/schema/beans"
11+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
12+
xmlns:aop="http://www.springframework.org/schema/aop"
13+
xmlns:tx="http://www.springframework.org/schema/tx"
14+
xmlns:context="http://www.springframework.org/schema/context"
15+
xsi:schemaLocation="
16+
http://www.springframework.org/schema/beans
17+
http://www.springframework.org/schema/beans/spring-beans.xsd
18+
http://www.springframework.org/schema/tx
19+
http://www.springframework.org/schema/tx/spring-tx.xsd
20+
http://www.springframework.org/schema/context
21+
http://www.springframework.org/schema/context/spring-context.xsd
22+
http://www.springframework.org/schema/aop
23+
http://www.springframework.org/schema/aop/spring-aop.xsd">
24+
25+
26+
</beans>

pom.xml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
<module>mybatis</module>
1414
<module>spring-webmvc</module>
1515
<module>spring-nosql</module>
16-
<module>spring</module>
1716
<module>dubbo</module>
1817
<module>log</module>
1918
<module>spring-mq</module>
@@ -644,6 +643,13 @@
644643
<version>2.3</version>
645644
</dependency>
646645

646+
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
647+
<dependency>
648+
<groupId>org.projectlombok</groupId>
649+
<artifactId>lombok</artifactId>
650+
<version>1.16.12</version>
651+
</dependency>
652+
647653
</dependencies>
648654
</dependencyManagement>
649655

@@ -783,6 +789,10 @@
783789
<artifactId>logback-ext-spring</artifactId>
784790
</dependency>
785791

792+
<dependency>
793+
<groupId>org.projectlombok</groupId>
794+
<artifactId>lombok</artifactId>
795+
</dependency>
786796

787797
</dependencies>
788798

spring-core/pom.xml

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,32 @@
1616
<dependency>
1717
<groupId>junit</groupId>
1818
<artifactId>junit</artifactId>
19-
<scope>test</scope>
19+
</dependency>
20+
21+
<dependency>
22+
<groupId>org.apache.zookeeper</groupId>
23+
<artifactId>zookeeper</artifactId>
24+
</dependency>
25+
26+
<dependency>
27+
<groupId>io.netty</groupId>
28+
<artifactId>netty-all</artifactId>
29+
</dependency>
30+
31+
<dependency>
32+
<groupId>org.objenesis</groupId>
33+
<artifactId>objenesis</artifactId>
34+
</dependency>
35+
36+
37+
<!-- Protostuff -->
38+
<dependency>
39+
<groupId>com.dyuproject.protostuff</groupId>
40+
<artifactId>protostuff-core</artifactId>
41+
</dependency>
42+
<dependency>
43+
<groupId>com.dyuproject.protostuff</groupId>
44+
<artifactId>protostuff-runtime</artifactId>
2045
</dependency>
2146

2247
<!-- aspectj -->
@@ -78,6 +103,12 @@
78103
<groupId>org.springframework</groupId>
79104
<artifactId>spring-test</artifactId>
80105
</dependency>
106+
<dependency>
107+
<!--spring 对 jedis的封装(jedisTemplate) -->
108+
<groupId>org.springframework.data</groupId>
109+
<artifactId>spring-data-redis</artifactId>
110+
</dependency>
111+
81112
<!--aop-->
82113
<dependency>
83114
<groupId>cglib</groupId>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.spring.core.aop;
2+
3+
import lombok.extern.slf4j.Slf4j;
4+
import org.aspectj.lang.JoinPoint;
5+
import org.aspectj.lang.annotation.Before;
6+
import org.aspectj.lang.annotation.Pointcut;
7+
import org.springframework.stereotype.Component;
8+
9+
/**
10+
* fuquanemail@gmail.com
11+
*/
12+
@Slf4j
13+
@org.aspectj.lang.annotation.Aspect
14+
@Component
15+
public class Aspect {
16+
17+
@Pointcut("@annotation(com.spring.core.aop.AspectAnnotation)")
18+
public void annotation() {
19+
}
20+
21+
@Before("annotation() && @annotation(aspectAnnotation)")
22+
public void beforeAdvice(JoinPoint joinPoint, AspectAnnotation aspectAnnotation) {
23+
log.info("beforeAdvice aspectAnnotation={}", aspectAnnotation);
24+
25+
if("123".equals(aspectAnnotation.value())){
26+
throw new RuntimeException("异常拦截");
27+
}
28+
}
29+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.spring.core.aop;
2+
3+
import java.lang.annotation.*;
4+
5+
6+
@Retention(RetentionPolicy.RUNTIME)
7+
@Target(value = {ElementType.METHOD})
8+
@Documented
9+
public @interface AspectAnnotation {
10+
11+
String value() default "";
12+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.spring.core.aop;
2+
3+
import lombok.extern.slf4j.Slf4j;
4+
import org.springframework.stereotype.Service;
5+
6+
@Slf4j
7+
@Service
8+
public class HelloService {
9+
10+
@AspectAnnotation("123")
11+
public String sayHello(String name) {
12+
log.info("sayHello.");
13+
return "hello:" + name;
14+
}
15+
16+
}
File renamed without changes.

spring/src/main/java/spring/cache/aop/CacheAspect.java renamed to spring-core/src/main/java/spring/cache/aop/CacheAspect.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import org.aspectj.lang.annotation.Around;
66
import org.slf4j.Logger;
77
import org.slf4j.LoggerFactory;
8+
89
import org.springframework.data.redis.core.RedisTemplate;
910
import org.springframework.data.redis.core.ValueOperations;
1011
import org.springframework.stereotype.Component;
File renamed without changes.

spring/src/main/java/spring/cache/common/AccountService.java renamed to spring-core/src/main/java/spring/cache/common/AccountService.java

File renamed without changes.

0 commit comments

Comments
 (0)