forked from lenve/javaboy-code-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
47 changed files
with
1,965 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<version>2.5.4</version> | ||
<relativePath/> <!-- lookup parent from repository --> | ||
</parent> | ||
<groupId>org.javaboy</groupId> | ||
<artifactId>eureka</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<name>eureka</name> | ||
<description>Demo project for Spring Boot</description> | ||
<properties> | ||
<java.version>11</java.version> | ||
<spring-cloud.version>2020.0.3</spring-cloud.version> | ||
</properties> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-security</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.cloud</groupId> | ||
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.security</groupId> | ||
<artifactId>spring-security-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.cloud</groupId> | ||
<artifactId>spring-cloud-dependencies</artifactId> | ||
<version>${spring-cloud.version}</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
15 changes: 15 additions & 0 deletions
15
mq_transaction/eureka/src/main/java/org/javaboy/eureka/EurekaApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.javaboy.eureka; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; | ||
|
||
@SpringBootApplication | ||
@EnableEurekaServer | ||
public class EurekaApplication { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(EurekaApplication.class, args); | ||
} | ||
|
||
} |
26 changes: 26 additions & 0 deletions
26
mq_transaction/eureka/src/main/java/org/javaboy/eureka/SecurityConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.javaboy.eureka; | ||
|
||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.security.config.annotation.web.builders.HttpSecurity; | ||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; | ||
|
||
/** | ||
* @author 江南一点雨 | ||
* @微信公众号 江南一点雨 | ||
* @网站 http://www.itboyhub.com | ||
* @国际站 http://www.javaboy.org | ||
* @微信 a_java_boy | ||
* @GitHub https://github.com/lenve | ||
* @Gitee https://gitee.com/lenve | ||
*/ | ||
@Configuration | ||
public class SecurityConfig extends WebSecurityConfigurerAdapter { | ||
@Override | ||
protected void configure(HttpSecurity http) throws Exception { | ||
http.authorizeRequests() | ||
.anyRequest().authenticated() | ||
.and() | ||
.httpBasic() | ||
.and().formLogin().and().csrf().disable(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
server: | ||
port: 8761 | ||
spring: | ||
application: | ||
name: eureka | ||
security: | ||
user: | ||
name: javaboy | ||
password: 123 | ||
eureka: | ||
client: | ||
register-with-eureka: false | ||
fetch-registry: false | ||
serviceUrl: | ||
defaultZone: http://javaboy:123@localhost:${server.port}/eureka/ |
13 changes: 13 additions & 0 deletions
13
mq_transaction/eureka/src/test/java/org/javaboy/eureka/EurekaApplicationTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.javaboy.eureka; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
|
||
@SpringBootTest | ||
class EurekaApplicationTests { | ||
|
||
@Test | ||
void contextLoads() { | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<version>2.5.4</version> | ||
<relativePath/> <!-- lookup parent from repository --> | ||
</parent> | ||
<groupId>org.javaboy</groupId> | ||
<artifactId>order</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<name>order</name> | ||
<description>Demo project for Spring Boot</description> | ||
<properties> | ||
<java.version>11</java.version> | ||
<spring-cloud.version>2020.0.3</spring-cloud.version> | ||
</properties> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-amqp</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-data-jpa</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.cloud</groupId> | ||
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId> | ||
</dependency> | ||
<dependency> | ||
<artifactId>service</artifactId> | ||
<groupId>org.javaboy</groupId> | ||
<version>1.0-SNAPSHOT</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>mysql</groupId> | ||
<artifactId>mysql-connector-java</artifactId> | ||
<scope>runtime</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.amqp</groupId> | ||
<artifactId>spring-rabbit-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.cloud</groupId> | ||
<artifactId>spring-cloud-dependencies</artifactId> | ||
<version>${spring-cloud.version}</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
13 changes: 13 additions & 0 deletions
13
mq_transaction/order/src/main/java/org/javaboy/order/OrderApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.javaboy.order; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
@SpringBootApplication | ||
public class OrderApplication { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(OrderApplication.class, args); | ||
} | ||
|
||
} |
49 changes: 49 additions & 0 deletions
49
mq_transaction/order/src/main/java/org/javaboy/order/config/JmsConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package org.javaboy.order.config; | ||
|
||
import org.springframework.context.annotation.Configuration; | ||
|
||
/** | ||
* Created by mavlarn on 2018/3/17. | ||
*/ | ||
@Configuration | ||
public class JmsConfig { | ||
|
||
// @Bean | ||
// public ConnectionFactory connectionFactory() { | ||
// ConnectionFactory cf = new ActiveMQConnectionFactory("tcp://localhost:61616"); | ||
// TransactionAwareConnectionFactoryProxy proxy = new TransactionAwareConnectionFactoryProxy(); | ||
// proxy.setTargetConnectionFactory(cf); | ||
// proxy.setSynchedLocalTransactionAllowed(true); | ||
// return proxy; | ||
// } | ||
// | ||
// @Bean | ||
// public JmsTemplate jmsTemplate(ConnectionFactory connectionFactory, MessageConverter jacksonJmsMessageConverter) { | ||
// JmsTemplate jmsTemplate = new JmsTemplate(connectionFactory); | ||
// jmsTemplate.setMessageConverter(jacksonJmsMessageConverter); | ||
// jmsTemplate.setSessionTransacted(true); | ||
// return jmsTemplate; | ||
// } | ||
// | ||
// @Bean | ||
// public JmsListenerContainerFactory<?> msgFactory(ConnectionFactory cf, | ||
// PlatformTransactionManager transactionManager, | ||
// DefaultJmsListenerContainerFactoryConfigurer configurer) { | ||
// DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory(); | ||
// configurer.configure(factory, cf); | ||
// factory.setReceiveTimeout(10000L); | ||
// // FIXME: 使用非内置的activeMQ服务器,这个就不需要, | ||
//// factory.setCacheLevelName("CACHE_CONNECTION"); | ||
// factory.setTransactionManager(transactionManager); | ||
// factory.setConcurrency("10"); | ||
// return factory; | ||
// } | ||
// | ||
// @Bean | ||
// public MessageConverter jacksonJmsMessageConverter() { | ||
// MappingJackson2MessageConverter converter = new MappingJackson2MessageConverter(); | ||
// converter.setTargetType(MessageType.TEXT); | ||
// converter.setTypeIdPropertyName("_type"); | ||
// return converter; | ||
// } | ||
} |
48 changes: 48 additions & 0 deletions
48
mq_transaction/order/src/main/java/org/javaboy/order/config/RabbitConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package org.javaboy.order.config; | ||
|
||
import org.springframework.amqp.core.Queue; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
public class RabbitConfig { | ||
|
||
@Bean | ||
Queue orderLockedQueue() { | ||
return new Queue("order:locked"); | ||
} | ||
|
||
|
||
@Bean | ||
Queue orderFinishQueue() { | ||
return new Queue("order:finish"); | ||
} | ||
|
||
|
||
@Bean | ||
Queue orderFailQueue() { | ||
return new Queue("order:fail"); | ||
} | ||
|
||
|
||
@Bean | ||
Queue orderNewQueue() { | ||
return new Queue("order:new"); | ||
} | ||
|
||
@Bean | ||
Queue orderTicketMoveQueue() { | ||
return new Queue("order:ticket_move"); | ||
} | ||
|
||
@Bean | ||
Queue orderTicketErrorQueue() { | ||
return new Queue("order:ticket_error"); | ||
} | ||
|
||
@Bean | ||
Queue orderPayQueue() { | ||
return new Queue("order:pay"); | ||
} | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
mq_transaction/order/src/main/java/org/javaboy/order/dao/OrderRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.javaboy.order.dao; | ||
|
||
|
||
import org.javaboy.order.domain.Order; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import java.time.ZonedDateTime; | ||
import java.util.List; | ||
|
||
/** | ||
* Created by mavlarn on 2018/1/20. | ||
*/ | ||
public interface OrderRepository extends JpaRepository<Order, Long> { | ||
|
||
List<Order> findAllByCustomerId(Long customerId); | ||
|
||
List<Order> findAllByStatusAndCreatedDateBefore(String status, ZonedDateTime checkTime); | ||
|
||
Order findOneByUuid(String uuid); | ||
} |
Oops, something went wrong.