From bbf8a77713fc0b71dcd984c954fa844b60675015 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BA=AF=E6=B4=81=E7=9A=84=E5=BE=AE=E7=AC=91?= Date: Thu, 5 Apr 2018 20:43:56 +0800 Subject: [PATCH] m --- README.md | 2 +- README_EN.md | 1 - spring-boot-atomikos/pom.xml | 60 ------------- spring-boot-atomikos/spring-boot-atomikos.iml | 15 ---- .../java/com/neo/JtaAtomikosApplication.java | 12 --- .../java/com/neo/config/DataSourceConfig.java | 30 ------- .../java/com/neo/config/PrimaryConfig.java | 63 ------------- .../java/com/neo/config/SecondaryConfig.java | 58 ------------ .../com/neo/controller/HelloController.java | 13 --- .../src/main/java/com/neo/model/User.java | 88 ------------------- .../repository/test1/UserTest1Repository.java | 19 ---- .../repository/test2/UserTest2Repository.java | 16 ---- .../src/main/resources/application.properties | 15 ---- .../java/com/neo/HelloApplicationTests.java | 18 ---- .../neo/repository/UserRepositoryTests.java | 57 ------------ .../target/classes/application.properties | 15 ---- .../compile/default-compile/createdFiles.lst | 0 .../compile/default-compile/inputFiles.lst | 8 -- spring-boot-elasticsearch/pom.xml | 51 ----------- .../com/neo/ElasticsearchApplication.java | 12 --- .../src/main/java/com/neo/model/Customer.java | 55 ------------ .../neo/repository/CustomerRepository.java | 17 ---- .../src/main/resources/application.properties | 1 - .../neo/ElasticsearchApplicationTests.java | 18 ---- .../repository/CustomerRepositoryTest.java | 64 -------------- 25 files changed, 1 insertion(+), 707 deletions(-) delete mode 100644 spring-boot-atomikos/pom.xml delete mode 100644 spring-boot-atomikos/spring-boot-atomikos.iml delete mode 100644 spring-boot-atomikos/src/main/java/com/neo/JtaAtomikosApplication.java delete mode 100644 spring-boot-atomikos/src/main/java/com/neo/config/DataSourceConfig.java delete mode 100644 spring-boot-atomikos/src/main/java/com/neo/config/PrimaryConfig.java delete mode 100644 spring-boot-atomikos/src/main/java/com/neo/config/SecondaryConfig.java delete mode 100644 spring-boot-atomikos/src/main/java/com/neo/controller/HelloController.java delete mode 100644 spring-boot-atomikos/src/main/java/com/neo/model/User.java delete mode 100644 spring-boot-atomikos/src/main/java/com/neo/repository/test1/UserTest1Repository.java delete mode 100644 spring-boot-atomikos/src/main/java/com/neo/repository/test2/UserTest2Repository.java delete mode 100644 spring-boot-atomikos/src/main/resources/application.properties delete mode 100644 spring-boot-atomikos/src/test/java/com/neo/HelloApplicationTests.java delete mode 100644 spring-boot-atomikos/src/test/java/com/neo/repository/UserRepositoryTests.java delete mode 100644 spring-boot-atomikos/target/classes/application.properties delete mode 100644 spring-boot-atomikos/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst delete mode 100644 spring-boot-atomikos/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst delete mode 100644 spring-boot-elasticsearch/pom.xml delete mode 100644 spring-boot-elasticsearch/src/main/java/com/neo/ElasticsearchApplication.java delete mode 100644 spring-boot-elasticsearch/src/main/java/com/neo/model/Customer.java delete mode 100644 spring-boot-elasticsearch/src/main/java/com/neo/repository/CustomerRepository.java delete mode 100644 spring-boot-elasticsearch/src/main/resources/application.properties delete mode 100644 spring-boot-elasticsearch/src/test/java/com/neo/ElasticsearchApplicationTests.java delete mode 100644 spring-boot-elasticsearch/src/test/java/com/neo/repository/CustomerRepositoryTest.java diff --git a/README.md b/README.md index 65e785b..8b2fc97 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Spring Boot 使用的各种示例,以最简单、最实用为标准 - [dockercompose-springboot-mysql-nginx](https://github.com/ityouknow/spring-boot-examples/tree/master/dockercompose-springboot-mysql-nginx) :Docker Compose + Spring Boot + Nginx + Mysql 示例 - [spring-boot-commandLineRunner](https://github.com/ityouknow/spring-boot-examples/tree/master/spring-boot-commandLineRunner) :Spring Boot 使用 commandLineRunner 实现项目启动时资源初始化示例 - [spring-boot-web-thymeleaf](https://github.com/ityouknow/spring-boot-examples/tree/master/spring-boot-web-thymeleaf) :Spring Boot 使用 thymeleaf 实现布局、验参、增删改查示例 -- [spring-boot-elasticsearch](https://github.com/ityouknow/spring-boot-examples/tree/master/spring-boot-elasticsearch) :Spring Boot 使用 Elasticsearch 增删改查示例 + **参考文章** diff --git a/README_EN.md b/README_EN.md index d06ed7f..1f0e232 100644 --- a/README_EN.md +++ b/README_EN.md @@ -18,7 +18,6 @@ Spring Boot examples, using the simplest and the most useful scene demos. - [dockercompose-springboot-mysql-nginx](https://github.com/ityouknow/spring-boot-examples/tree/master/dockercompose-springboot-mysql-nginx) :Docker Compose + Spring Boot + Nginx + Mysql example - [spring-boot-commandLineRunner](https://github.com/ityouknow/spring-boot-examples/tree/master/spring-boot-commandLineRunner) :Example of resource initialization at project startup using Spring Boot and commandLineRunner - [spring-boot-web-thymeleaf](https://github.com/ityouknow/spring-boot-examples/tree/master/spring-boot-web-thymeleaf) :Spring Boot uses thymeleaf to implement layout, check parameters and CURD -- [spring-boot-elasticsearch](https://github.com/ityouknow/spring-boot-examples/tree/master/spring-boot-elasticsearch) :Spring Boot uses Elasticsearch CURD demo --- diff --git a/spring-boot-atomikos/pom.xml b/spring-boot-atomikos/pom.xml deleted file mode 100644 index 67e5858..0000000 --- a/spring-boot-atomikos/pom.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - 4.0.0 - - com.neo - spring-boot-atomikos - 1.0 - jar - - spring-boot-atomikos - Demo project for Spring Boot - - - org.springframework.boot - spring-boot-starter-parent - 2.0.0.RELEASE - - - - - UTF-8 - 1.8 - - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-data-jpa - - - org.springframework.boot - spring-boot-starter-jta-atomikos - - - mysql - mysql-connector-java - - - org.springframework.boot - spring-boot-starter-test - test - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - - - diff --git a/spring-boot-atomikos/spring-boot-atomikos.iml b/spring-boot-atomikos/spring-boot-atomikos.iml deleted file mode 100644 index 73f608b..0000000 --- a/spring-boot-atomikos/spring-boot-atomikos.iml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/spring-boot-atomikos/src/main/java/com/neo/JtaAtomikosApplication.java b/spring-boot-atomikos/src/main/java/com/neo/JtaAtomikosApplication.java deleted file mode 100644 index cab4f8b..0000000 --- a/spring-boot-atomikos/src/main/java/com/neo/JtaAtomikosApplication.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.neo; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class JtaAtomikosApplication { - - public static void main(String[] args) { - SpringApplication.run(JtaAtomikosApplication.class, args); - } -} diff --git a/spring-boot-atomikos/src/main/java/com/neo/config/DataSourceConfig.java b/spring-boot-atomikos/src/main/java/com/neo/config/DataSourceConfig.java deleted file mode 100644 index 2fe83cf..0000000 --- a/spring-boot-atomikos/src/main/java/com/neo/config/DataSourceConfig.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.neo.config; - -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Primary; - -import javax.sql.DataSource; - -@Configuration -public class DataSourceConfig { - - @Bean(name = "primaryDataSource") - @Qualifier("primaryDataSource") - @ConfigurationProperties(prefix="spring.primary.datasource") - public DataSource primaryDataSource() { - return new AtomikosDataSourceBean(); - } - - @Bean(name = "secondaryDataSource") - @Qualifier("secondaryDataSource") - @Primary - @ConfigurationProperties(prefix="spring.secondary.datasource") - public DataSource secondaryDataSource() { - return new AtomikosDataSourceBean(); - } - -} diff --git a/spring-boot-atomikos/src/main/java/com/neo/config/PrimaryConfig.java b/spring-boot-atomikos/src/main/java/com/neo/config/PrimaryConfig.java deleted file mode 100644 index cdf8005..0000000 --- a/spring-boot-atomikos/src/main/java/com/neo/config/PrimaryConfig.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.neo.config; - -import java.util.Map; - -import javax.persistence.EntityManager; -import javax.sql.DataSource; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.boot.autoconfigure.orm.jpa.JpaProperties; -import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Primary; -import org.springframework.data.jpa.repository.config.EnableJpaRepositories; -import org.springframework.orm.jpa.JpaTransactionManager; -import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; -import org.springframework.transaction.PlatformTransactionManager; -import org.springframework.transaction.annotation.EnableTransactionManagement; - -@Configuration -@EnableTransactionManagement -@EnableJpaRepositories( - entityManagerFactoryRef="entityManagerFactoryPrimary", - transactionManagerRef="transactionManagerPrimary", - basePackages= { "com.neo.repository.test1" })//设置dao(repo)所在位置 -public class PrimaryConfig { - - @Autowired - private JpaProperties jpaProperties; - - @Autowired - @Qualifier("primaryDataSource") - private DataSource primaryDataSource; - - @Bean(name = "entityManagerPrimary") - @Primary - public EntityManager entityManager(EntityManagerFactoryBuilder builder) { - return entityManagerFactoryPrimary(builder).getObject().createEntityManager(); - } - - @Bean(name = "entityManagerFactoryPrimary") - @Primary - public LocalContainerEntityManagerFactoryBean entityManagerFactoryPrimary (EntityManagerFactoryBuilder builder) { - return builder - .dataSource(primaryDataSource) - .properties(getVendorProperties(primaryDataSource)) - .packages("com.neo.domain") //设置实体类所在位置 - .persistenceUnit("primaryPersistenceUnit") - .build(); - } - - private Map getVendorProperties(DataSource dataSource) { - return jpaProperties.getHibernateProperties(dataSource); - } - - @Bean(name = "transactionManagerPrimary") - @Primary - PlatformTransactionManager transactionManagerPrimary(EntityManagerFactoryBuilder builder) { - return new JpaTransactionManager(entityManagerFactoryPrimary(builder).getObject()); - } - -} \ No newline at end of file diff --git a/spring-boot-atomikos/src/main/java/com/neo/config/SecondaryConfig.java b/spring-boot-atomikos/src/main/java/com/neo/config/SecondaryConfig.java deleted file mode 100644 index 861f461..0000000 --- a/spring-boot-atomikos/src/main/java/com/neo/config/SecondaryConfig.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.neo.config; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.boot.autoconfigure.orm.jpa.JpaProperties; -import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Primary; -import org.springframework.data.jpa.repository.config.EnableJpaRepositories; -import org.springframework.orm.jpa.JpaTransactionManager; -import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; -import org.springframework.transaction.PlatformTransactionManager; -import org.springframework.transaction.annotation.EnableTransactionManagement; - -import javax.persistence.EntityManager; -import javax.sql.DataSource; -import java.util.Map; - -@Configuration -@EnableTransactionManagement -@EnableJpaRepositories( - entityManagerFactoryRef="entityManagerFactorySecondary", - transactionManagerRef="transactionManagerSecondary", - basePackages= { "com.neo.repository.test2" }) -public class SecondaryConfig { - @Autowired - private JpaProperties jpaProperties; - - @Autowired - @Qualifier("secondaryDataSource") - private DataSource secondaryDataSource; - - @Bean(name = "entityManagerSecondary") - public EntityManager entityManager(EntityManagerFactoryBuilder builder) { - return entityManagerFactorySecondary(builder).getObject().createEntityManager(); - } - - @Bean(name = "entityManagerFactorySecondary") - public LocalContainerEntityManagerFactoryBean entityManagerFactorySecondary (EntityManagerFactoryBuilder builder) { - return builder - .dataSource(secondaryDataSource) - .properties(getVendorProperties(secondaryDataSource)) - .packages("com.neo.domain") - .persistenceUnit("secondaryPersistenceUnit") - .build(); - } - - private Map getVendorProperties(DataSource dataSource) { - return jpaProperties.getHibernateProperties(dataSource); - } - - @Bean(name = "transactionManagerSecondary") - PlatformTransactionManager transactionManagerSecondary(EntityManagerFactoryBuilder builder) { - return new JpaTransactionManager(entityManagerFactorySecondary(builder).getObject()); - } - -} \ No newline at end of file diff --git a/spring-boot-atomikos/src/main/java/com/neo/controller/HelloController.java b/spring-boot-atomikos/src/main/java/com/neo/controller/HelloController.java deleted file mode 100644 index 2c1c06d..0000000 --- a/spring-boot-atomikos/src/main/java/com/neo/controller/HelloController.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.neo.controller; - -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class HelloController { - - @RequestMapping("/") - public String index() { - return "Hello Spring Boot 2.0!"; - } -} \ No newline at end of file diff --git a/spring-boot-atomikos/src/main/java/com/neo/model/User.java b/spring-boot-atomikos/src/main/java/com/neo/model/User.java deleted file mode 100644 index 76234d4..0000000 --- a/spring-boot-atomikos/src/main/java/com/neo/model/User.java +++ /dev/null @@ -1,88 +0,0 @@ -package com.neo.domain; - - - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; - -import java.io.Serializable; - -@Entity -public class User implements Serializable { - - private static final long serialVersionUID = 1L; - @Id - @GeneratedValue - private Long id; - @Column(nullable = false, unique = true) - private String userName; - @Column(nullable = false) - private String passWord; - @Column(nullable = false, unique = true) - private String email; - @Column(nullable = true, unique = true) - private String nickName; - @Column(nullable = false) - private String regTime; - - public User() { - } - - public User(String userName, String passWord, String email, String nickName, String regTime) { - this.userName = userName; - this.passWord = passWord; - this.email = email; - this.nickName = nickName; - this.regTime = regTime; - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getUserName() { - return userName; - } - - public void setUserName(String userName) { - this.userName = userName; - } - - public String getPassWord() { - return passWord; - } - - public void setPassWord(String passWord) { - this.passWord = passWord; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public String getNickName() { - return nickName; - } - - public void setNickName(String nickName) { - this.nickName = nickName; - } - - public String getRegTime() { - return regTime; - } - - public void setRegTime(String regTime) { - this.regTime = regTime; - } -} diff --git a/spring-boot-atomikos/src/main/java/com/neo/repository/test1/UserTest1Repository.java b/spring-boot-atomikos/src/main/java/com/neo/repository/test1/UserTest1Repository.java deleted file mode 100644 index 5dc88ac..0000000 --- a/spring-boot-atomikos/src/main/java/com/neo/repository/test1/UserTest1Repository.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.neo.repository.test1; - -import com.neo.domain.User; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.Modifying; -import org.springframework.data.jpa.repository.Query; -import org.springframework.stereotype.Component; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import javax.annotation.Resource; -import java.util.List; - -public interface UserTest1Repository extends JpaRepository { - User findByUserName(String userName); - User findByUserNameOrEmail(String username, String email); -} \ No newline at end of file diff --git a/spring-boot-atomikos/src/main/java/com/neo/repository/test2/UserTest2Repository.java b/spring-boot-atomikos/src/main/java/com/neo/repository/test2/UserTest2Repository.java deleted file mode 100644 index 32b25b2..0000000 --- a/spring-boot-atomikos/src/main/java/com/neo/repository/test2/UserTest2Repository.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.neo.repository.test2; - -import com.neo.domain.User; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.Modifying; -import org.springframework.data.jpa.repository.Query; -import org.springframework.stereotype.Component; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -public interface UserTest2Repository extends JpaRepository { - User findByUserName(String userName); - User findByUserNameOrEmail(String username, String email); -} \ No newline at end of file diff --git a/spring-boot-atomikos/src/main/resources/application.properties b/spring-boot-atomikos/src/main/resources/application.properties deleted file mode 100644 index 10b7bb3..0000000 --- a/spring-boot-atomikos/src/main/resources/application.properties +++ /dev/null @@ -1,15 +0,0 @@ -#primary -spring.primary.datasource.url=jdbc:mysql://localhost:3306/test1 -spring.primary.datasource.username=root -spring.primary.datasource.password=root -spring.primary.datasource.driver-class-name=com.mysql.jdbc.Driver -#secondary -spring.secondary.datasource.url=jdbc:mysql://localhost:3306/test2 -spring.secondary.datasource.username=root -spring.secondary.datasource.password=root -spring.secondary.datasource.driver-class-name=com.mysql.jdbc.Driver -#multiple Setting - -spring.jpa.properties.hibernate.hbm2ddl.auto=update -spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect -spring.jpa.show-sql= true \ No newline at end of file diff --git a/spring-boot-atomikos/src/test/java/com/neo/HelloApplicationTests.java b/spring-boot-atomikos/src/test/java/com/neo/HelloApplicationTests.java deleted file mode 100644 index 09ba4ff..0000000 --- a/spring-boot-atomikos/src/test/java/com/neo/HelloApplicationTests.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.neo; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.junit4.SpringRunner; - -@RunWith(SpringRunner.class) -@SpringBootTest -public class HelloApplicationTests { - - @Test - public void contextLoads() { - System.out.println("Hello Spring Boot 2.0!"); - } - -} diff --git a/spring-boot-atomikos/src/test/java/com/neo/repository/UserRepositoryTests.java b/spring-boot-atomikos/src/test/java/com/neo/repository/UserRepositoryTests.java deleted file mode 100644 index d1f1ae6..0000000 --- a/spring-boot-atomikos/src/test/java/com/neo/repository/UserRepositoryTests.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.neo.repository; - -import com.neo.domain.User; -import com.neo.repository.test1.UserTest1Repository; -import com.neo.repository.test2.UserTest2Repository; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Sort; -import org.springframework.test.context.junit4.SpringRunner; - -import javax.annotation.Resource; -import java.text.DateFormat; -import java.util.Date; - -@RunWith(SpringRunner.class) -@SpringBootTest -public class UserRepositoryTests { - @Resource - private UserTest1Repository userTest1Repository; - @Resource - private UserTest2Repository userTest2Repository; - - @Test - @Transactional - public void testSave() throws Exception { - Date date = new Date(); - DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG); - String formattedDate = dateFormat.format(date); - - userTest1Repository.save(new User("aa", "aa123456","aa@126.com", "aa", formattedDate)); - userTest1Repository.save(new User("bb", "bb123456","bb@126.com", "bb", formattedDate)); - userTest2Repository.save(new User("cc", "cc123456","cc@126.com", "cc", formattedDate)); - - } - - - @Test - public void testBaseQuery() { - Date date = new Date(); - DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG); - String formattedDate = dateFormat.format(date); - User user=new User("ff", "ff123456","ff@126.com", "ff", formattedDate); - userTest1Repository.findAll(); - userTest2Repository.findOne(3l); - userTest2Repository.save(user); - user.setId(2l); - userTest1Repository.delete(user); - userTest1Repository.count(); - userTest2Repository.exists(3l); - } - - -} \ No newline at end of file diff --git a/spring-boot-atomikos/target/classes/application.properties b/spring-boot-atomikos/target/classes/application.properties deleted file mode 100644 index 10b7bb3..0000000 --- a/spring-boot-atomikos/target/classes/application.properties +++ /dev/null @@ -1,15 +0,0 @@ -#primary -spring.primary.datasource.url=jdbc:mysql://localhost:3306/test1 -spring.primary.datasource.username=root -spring.primary.datasource.password=root -spring.primary.datasource.driver-class-name=com.mysql.jdbc.Driver -#secondary -spring.secondary.datasource.url=jdbc:mysql://localhost:3306/test2 -spring.secondary.datasource.username=root -spring.secondary.datasource.password=root -spring.secondary.datasource.driver-class-name=com.mysql.jdbc.Driver -#multiple Setting - -spring.jpa.properties.hibernate.hbm2ddl.auto=update -spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect -spring.jpa.show-sql= true \ No newline at end of file diff --git a/spring-boot-atomikos/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/spring-boot-atomikos/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst deleted file mode 100644 index e69de29..0000000 diff --git a/spring-boot-atomikos/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/spring-boot-atomikos/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst deleted file mode 100644 index 973647f..0000000 --- a/spring-boot-atomikos/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst +++ /dev/null @@ -1,8 +0,0 @@ -/neo/hello/spring-boot-atomikos/src/main/java/com/neo/config/SecondaryConfig.java -/neo/hello/spring-boot-atomikos/src/main/java/com/neo/JtaAtomikosApplication.java -/neo/hello/spring-boot-atomikos/src/main/java/com/neo/model/User.java -/neo/hello/spring-boot-atomikos/src/main/java/com/neo/repository/test1/UserTest1Repository.java -/neo/hello/spring-boot-atomikos/src/main/java/com/neo/config/PrimaryConfig.java -/neo/hello/spring-boot-atomikos/src/main/java/com/neo/controller/HelloController.java -/neo/hello/spring-boot-atomikos/src/main/java/com/neo/config/DataSourceConfig.java -/neo/hello/spring-boot-atomikos/src/main/java/com/neo/repository/test2/UserTest2Repository.java diff --git a/spring-boot-elasticsearch/pom.xml b/spring-boot-elasticsearch/pom.xml deleted file mode 100644 index 969489a..0000000 --- a/spring-boot-elasticsearch/pom.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - 4.0.0 - - com.neo - spring-boot-elasticsearch - 1.0 - jar - - spring-boot-elasticsearch - Demo project for Spring Boot - - - org.springframework.boot - spring-boot-starter-parent - 2.0.0.RELEASE - - - - UTF-8 - 1.8 - - - - - org.springframework.boot - spring-boot-starter - - - org.springframework.boot - spring-boot-starter-data-elasticsearch - - - org.springframework.boot - spring-boot-starter-test - test - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - - - diff --git a/spring-boot-elasticsearch/src/main/java/com/neo/ElasticsearchApplication.java b/spring-boot-elasticsearch/src/main/java/com/neo/ElasticsearchApplication.java deleted file mode 100644 index e16db52..0000000 --- a/spring-boot-elasticsearch/src/main/java/com/neo/ElasticsearchApplication.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.neo; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class ElasticsearchApplication { - - public static void main(String[] args) { - SpringApplication.run(ElasticsearchApplication.class, args); - } -} diff --git a/spring-boot-elasticsearch/src/main/java/com/neo/model/Customer.java b/spring-boot-elasticsearch/src/main/java/com/neo/model/Customer.java deleted file mode 100644 index f8b52ec..0000000 --- a/spring-boot-elasticsearch/src/main/java/com/neo/model/Customer.java +++ /dev/null @@ -1,55 +0,0 @@ - -package com.neo.model; - -import org.springframework.data.annotation.Id; -import org.springframework.data.elasticsearch.annotations.Document; - -@Document(indexName = "customer", type = "customer", shards = 1, replicas = 0, refreshInterval = "-1") -public class Customer { - - @Id - private String id; - - private String userName; - - private String address; - - public Customer() { - } - - public Customer(String userName, String address) { - this.userName = userName; - this.address = address; - } - - public String getId() { - return this.id; - } - - public void setId(String id) { - this.id = id; - } - - public String getUserName() { - return userName; - } - - public void setUserName(String userName) { - this.userName = userName; - } - - public String getAddress() { - return address; - } - - public void setAddress(String address) { - this.address = address; - } - - @Override - public String toString() { - return String.format("Customer[id=%s, userName='%s', address='%s']", this.id, - this.userName, this.address); - } - -} diff --git a/spring-boot-elasticsearch/src/main/java/com/neo/repository/CustomerRepository.java b/spring-boot-elasticsearch/src/main/java/com/neo/repository/CustomerRepository.java deleted file mode 100644 index 569741e..0000000 --- a/spring-boot-elasticsearch/src/main/java/com/neo/repository/CustomerRepository.java +++ /dev/null @@ -1,17 +0,0 @@ - -package com.neo.repository; - -import com.neo.model.Customer; -import org.springframework.data.elasticsearch.repository.ElasticsearchRepository; - -import java.util.List; - -public interface CustomerRepository extends ElasticsearchRepository { - - public Customer findByUserName(String userName); - - public int deleteByUserName(String userName); - - public List findByAddress(String address); - -} diff --git a/spring-boot-elasticsearch/src/main/resources/application.properties b/spring-boot-elasticsearch/src/main/resources/application.properties deleted file mode 100644 index c8307bf..0000000 --- a/spring-boot-elasticsearch/src/main/resources/application.properties +++ /dev/null @@ -1 +0,0 @@ -spring.data.elasticsearch.cluster-nodes=localhost:9300 \ No newline at end of file diff --git a/spring-boot-elasticsearch/src/test/java/com/neo/ElasticsearchApplicationTests.java b/spring-boot-elasticsearch/src/test/java/com/neo/ElasticsearchApplicationTests.java deleted file mode 100644 index 4a07e8e..0000000 --- a/spring-boot-elasticsearch/src/test/java/com/neo/ElasticsearchApplicationTests.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.neo; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.junit4.SpringRunner; - -@RunWith(SpringRunner.class) -@SpringBootTest -public class ElasticsearchApplicationTests { - - @Test - public void contextLoads() { - System.out.println("Spring Boot Test"); - } - -} diff --git a/spring-boot-elasticsearch/src/test/java/com/neo/repository/CustomerRepositoryTest.java b/spring-boot-elasticsearch/src/test/java/com/neo/repository/CustomerRepositoryTest.java deleted file mode 100644 index 086855a..0000000 --- a/spring-boot-elasticsearch/src/test/java/com/neo/repository/CustomerRepositoryTest.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.neo.repository; - - -import com.neo.model.Customer; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; - -@RunWith(SpringRunner.class) -@SpringBootTest -public class CustomerRepositoryTest { - @Autowired - private CustomerRepository repository; - - @Test - public void saveCustomers() { - repository.save(new Customer("Alice", "北京")); - repository.save(new Customer("Bob", "北京")); - repository.save(new Customer("neo", "西安")); - repository.save(new Customer("summer", "烟台")); - } - - @Test - public void deleteCustomers() { -// repository.deleteAll(); - repository.deleteByUserName("neo"); - } - - @Test - public void updateCustomers() { - Customer customer= repository.findByUserName("summer"); - System.out.println(customer); - customer.setAddress("北京市海淀区西直门"); - repository.save(customer); - Customer xcustomer=repository.findByUserName("summer"); - System.out.println(xcustomer); - } - - @Test - public void fetchAllCustomers() { - System.out.println("Customers found with findAll():"); - System.out.println("-------------------------------"); - for (Customer customer : repository.findAll()) { - System.out.println(customer); - } - System.out.println(); - } - - @Test - public void fetchIndividualCustomers() { - System.out.println("Customer found with findByUserName('summer'):"); - System.out.println("--------------------------------"); - System.out.println(repository.findByUserName("summer")); - - System.out.println("Customers found with findByAddress(\"北京\"):"); - System.out.println("--------------------------------"); - for (Customer customer : repository.findByAddress("北京")) { - System.out.println(customer); - } - } - -}