-
Notifications
You must be signed in to change notification settings - Fork 40
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
22 changed files
with
238 additions
and
248 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
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
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
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
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
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
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
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
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
72 changes: 0 additions & 72 deletions
72
jdbc-demo/springcloud-jdbc-demo5/src/main/java/com/example/demo/DemoApplication.java
This file was deleted.
Oops, something went wrong.
71 changes: 71 additions & 0 deletions
71
jdbc-demo/springcloud-jdbc-demo5/src/main/java/com/example/demo/JdbcDemo5Application.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,71 @@ | ||
package com.example.demo; | ||
|
||
import com.alibaba.druid.pool.DruidDataSource; | ||
import com.lorne.tx.compensate.repository.CompensateDataSource; | ||
import com.lorne.tx.db.LCNDataSourceProxy; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.cloud.netflix.eureka.EnableEurekaClient; | ||
import org.springframework.cloud.netflix.feign.EnableFeignClients; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.core.env.Environment; | ||
|
||
import javax.sql.DataSource; | ||
|
||
@EnableAutoConfiguration | ||
@SpringBootApplication | ||
@EnableEurekaClient | ||
@EnableFeignClients | ||
public class JdbcDemo5Application { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(JdbcDemo5Application.class, args); | ||
} | ||
|
||
@Autowired | ||
private Environment env; | ||
|
||
@Bean | ||
public DataSource dataSource() { | ||
DruidDataSource dataSource = new DruidDataSource(); | ||
dataSource.setUrl(env.getProperty("spring.datasource.url")); | ||
dataSource.setUsername(env.getProperty("spring.datasource.username"));//用户名 | ||
dataSource.setPassword(env.getProperty("spring.datasource.password"));//密码 | ||
dataSource.setInitialSize(2); | ||
dataSource.setMaxActive(20); | ||
dataSource.setMinIdle(0); | ||
dataSource.setMaxWait(60000); | ||
dataSource.setValidationQuery("SELECT 1"); | ||
dataSource.setTestOnBorrow(false); | ||
dataSource.setTestWhileIdle(true); | ||
dataSource.setPoolPreparedStatements(false); | ||
|
||
LCNDataSourceProxy dataSourceProxy = new LCNDataSourceProxy(); | ||
dataSourceProxy.setDataSource(dataSource); | ||
dataSourceProxy.setMaxCount(10); | ||
return dataSourceProxy; | ||
} | ||
|
||
@Bean | ||
public CompensateDataSource compensateDataSource() { | ||
|
||
DruidDataSource dataSource = new DruidDataSource(); | ||
dataSource.setUrl(env.getProperty("spring.datasource.url")); | ||
dataSource.setUsername(env.getProperty("spring.datasource.username"));//用户名 | ||
dataSource.setPassword(env.getProperty("spring.datasource.password"));//密码 | ||
dataSource.setInitialSize(1); | ||
dataSource.setMaxActive(5); | ||
dataSource.setMinIdle(0); | ||
dataSource.setMaxWait(60000); | ||
dataSource.setValidationQuery("SELECT 1"); | ||
dataSource.setTestOnBorrow(false); | ||
dataSource.setTestWhileIdle(true); | ||
dataSource.setPoolPreparedStatements(false); | ||
|
||
CompensateDataSource compensateDataSource = new CompensateDataSource(); | ||
compensateDataSource.setDataSource(dataSource); | ||
return compensateDataSource; | ||
} | ||
} |
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
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
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
Oops, something went wrong.