├── git ├── doc ├── 1.png ├── 2.png ├── 3.png ├── 4.png ├── 5.png ├── 6.png ├── 7.png ├── 8.png ├── nice-fish.png ├── structure.png ├── nicefish-springcloud.jpg └── maven-module-dependency.png ├── nicefish-blog ├── src │ ├── main │ │ ├── resources │ │ │ └── application.yml │ │ └── java │ │ │ └── com │ │ │ └── fish │ │ │ └── blog │ │ │ ├── service │ │ │ ├── IPostService.java │ │ │ └── impl │ │ │ │ └── PostServiceImpl.java │ │ │ ├── repository │ │ │ ├── PostRepository.java │ │ │ └── CommentRepository.java │ │ │ ├── util │ │ │ └── ResponsePageImpl.java │ │ │ ├── NiceFishBlogApplication.java │ │ │ ├── config │ │ │ └── RedisConfig.java │ │ │ ├── controller │ │ │ ├── CommentController.java │ │ │ └── PostController.java │ │ │ └── entity │ │ │ ├── CommentEntity.java │ │ │ └── PostEntity.java │ └── test │ │ └── java │ │ └── com │ │ └── fish │ │ └── blog │ │ └── NiceFishBlogApplicationTests.java ├── .gitignore ├── pom.xml ├── mvnw.cmd └── mvnw ├── nicefish-oauth2-jwt ├── src │ ├── main │ │ ├── resources │ │ │ └── application.yml │ │ └── java │ │ │ └── com │ │ │ └── fish │ │ │ └── oauth │ │ │ ├── NiceFishOAuthApplication.java │ │ │ ├── service │ │ │ └── CustomUserDetailsService.java │ │ │ ├── entity │ │ │ └── CustomUserEntity.java │ │ │ ├── util │ │ │ └── JwtAccessTokenConverterEnhancer.java │ │ │ └── config │ │ │ ├── OAuthWebSecurityConfig.java │ │ │ └── OAuth2Config.java │ └── test │ │ └── java │ │ └── com │ │ └── fish │ │ └── oauth │ │ └── NiceFishOAuthApplicationTests.java ├── .gitignore ├── pom.xml ├── mvnw.cmd └── mvnw ├── nicefish-swagger2-api ├── src │ ├── main │ │ ├── resources │ │ │ └── application.yml │ │ └── java │ │ │ └── com │ │ │ └── fish │ │ │ └── swagger2 │ │ │ ├── NiceFishSwagger2ApiApplication.java │ │ │ └── config │ │ │ └── SwaggerConfig.java │ └── test │ │ └── java │ │ └── com │ │ └── fish │ │ └── swagger2 │ │ └── NiceFishSwagger2ApiApplicationTests.java ├── .gitignore ├── pom.xml ├── mvnw.cmd └── mvnw ├── nicefish-user-center ├── src │ ├── main │ │ ├── resources │ │ │ └── application.yml │ │ └── java │ │ │ └── com │ │ │ └── fish │ │ │ └── user │ │ │ ├── entity │ │ │ ├── RoleRepository.java │ │ │ ├── PermissionRepository.java │ │ │ ├── PermissionEntity.java │ │ │ ├── UserRepository.java │ │ │ ├── RoleEntity.java │ │ │ └── UserEntity.java │ │ │ ├── NiceFishUserCenterApplication.java │ │ │ ├── config │ │ │ ├── WebAppConfig.java │ │ │ ├── SecurityConfig.java │ │ │ └── FishJwtTokenConverter.java │ │ │ ├── util │ │ │ └── AjaxResponseEntity.java │ │ │ └── controller │ │ │ ├── PermissionController.java │ │ │ ├── RoleController.java │ │ │ └── UserController.java │ └── test │ │ └── java │ │ └── com │ │ └── fish │ │ └── user │ │ ├── RoleRepositoryTests.java │ │ ├── PermissionRepositoryTests.java │ │ └── UserRepositoryTests.java ├── .gitignore ├── pom.xml ├── mvnw.cmd └── mvnw ├── nicefish-zuul-server ├── src │ ├── main │ │ ├── resources │ │ │ └── application.yml │ │ └── java │ │ │ └── com │ │ │ └── fish │ │ │ └── zuul │ │ │ ├── NiceFishZuulServerApplication.java │ │ │ ├── config │ │ │ └── HystrixConfiguration.java │ │ │ ├── filter │ │ │ └── FishCorsFilter.java │ │ │ └── provider │ │ │ └── ApiFallbackProvider.java │ └── test │ │ └── java │ │ └── com │ │ └── fish │ │ └── zuul │ │ └── NiceFishZuulServerApplicationTests.java ├── .gitignore ├── pom.xml ├── mvnw.cmd └── mvnw ├── .gitignore ├── config ├── logback.xml └── application.yml ├── pom.xml └── README.md /git: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /doc/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/damoqiongqiu/nicefish-spring-cloud/HEAD/doc/1.png -------------------------------------------------------------------------------- /doc/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/damoqiongqiu/nicefish-spring-cloud/HEAD/doc/2.png -------------------------------------------------------------------------------- /doc/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/damoqiongqiu/nicefish-spring-cloud/HEAD/doc/3.png -------------------------------------------------------------------------------- /doc/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/damoqiongqiu/nicefish-spring-cloud/HEAD/doc/4.png -------------------------------------------------------------------------------- /doc/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/damoqiongqiu/nicefish-spring-cloud/HEAD/doc/5.png -------------------------------------------------------------------------------- /doc/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/damoqiongqiu/nicefish-spring-cloud/HEAD/doc/6.png -------------------------------------------------------------------------------- /doc/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/damoqiongqiu/nicefish-spring-cloud/HEAD/doc/7.png -------------------------------------------------------------------------------- /doc/8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/damoqiongqiu/nicefish-spring-cloud/HEAD/doc/8.png -------------------------------------------------------------------------------- /doc/nice-fish.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/damoqiongqiu/nicefish-spring-cloud/HEAD/doc/nice-fish.png -------------------------------------------------------------------------------- /doc/structure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/damoqiongqiu/nicefish-spring-cloud/HEAD/doc/structure.png -------------------------------------------------------------------------------- /doc/nicefish-springcloud.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/damoqiongqiu/nicefish-spring-cloud/HEAD/doc/nicefish-springcloud.jpg -------------------------------------------------------------------------------- /doc/maven-module-dependency.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/damoqiongqiu/nicefish-spring-cloud/HEAD/doc/maven-module-dependency.png -------------------------------------------------------------------------------- /nicefish-blog/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 9300 3 | 4 | spring: 5 | application: 6 | name: nicefish-blog -------------------------------------------------------------------------------- /nicefish-oauth2-jwt/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 9100 3 | 4 | spring: 5 | application: 6 | name: nicefish-oauth2-jwt -------------------------------------------------------------------------------- /nicefish-swagger2-api/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 9400 3 | 4 | spring: 5 | application: 6 | name: nicefish-swagger2-api -------------------------------------------------------------------------------- /nicefish-user-center/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 9200 3 | 4 | spring: 5 | application: 6 | name: nicefish-user-center -------------------------------------------------------------------------------- /nicefish-zuul-server/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 9500 3 | 4 | spring: 5 | application: 6 | name: nicefish-zuul-server -------------------------------------------------------------------------------- /nicefish-user-center/src/main/java/com/fish/user/entity/RoleRepository.java: -------------------------------------------------------------------------------- 1 | package com.fish.user.entity; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | 5 | /** 6 | * @author 大漠穷秋 7 | * @version 创建时间:2018-12-30 20:31 8 | */ 9 | public interface RoleRepository extends JpaRepository { 10 | } 11 | -------------------------------------------------------------------------------- /nicefish-user-center/src/main/java/com/fish/user/entity/PermissionRepository.java: -------------------------------------------------------------------------------- 1 | package com.fish.user.entity; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | 5 | /** 6 | * @author 大漠穷秋 7 | * @version 创建时间:2018-12-30 20:31 8 | */ 9 | public interface PermissionRepository extends JpaRepository { 10 | 11 | } 12 | -------------------------------------------------------------------------------- /nicefish-swagger2-api/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | .sts4-cache 12 | 13 | ### IntelliJ IDEA ### 14 | .idea 15 | *.iws 16 | *.iml 17 | *.ipr 18 | 19 | ### NetBeans ### 20 | /nbproject/private/ 21 | /build/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ -------------------------------------------------------------------------------- /nicefish-zuul-server/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | .sts4-cache 12 | 13 | ### IntelliJ IDEA ### 14 | .idea 15 | *.iws 16 | *.iml 17 | *.ipr 18 | 19 | ### NetBeans ### 20 | /nbproject/private/ 21 | /build/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | .sts4-cache 12 | 13 | ### IntelliJ IDEA ### 14 | .idea 15 | *.iws 16 | *.iml 17 | *.ipr 18 | .mvn 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /build/ 23 | /nbbuild/ 24 | /dist/ 25 | /nbdist/ 26 | /.nb-gradle/ 27 | 28 | /logs/ 29 | .mvn 30 | -------------------------------------------------------------------------------- /nicefish-blog/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | .sts4-cache 12 | 13 | ### IntelliJ IDEA ### 14 | .idea 15 | *.iws 16 | *.iml 17 | *.ipr 18 | .mvn 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /build/ 23 | /nbbuild/ 24 | /dist/ 25 | /nbdist/ 26 | /.nb-gradle/ 27 | /logs/ 28 | .mvn 29 | -------------------------------------------------------------------------------- /nicefish-oauth2-jwt/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | .sts4-cache 12 | 13 | ### IntelliJ IDEA ### 14 | .idea 15 | *.iws 16 | *.iml 17 | *.ipr 18 | .mvn 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /build/ 23 | /nbbuild/ 24 | /dist/ 25 | /nbdist/ 26 | /.nb-gradle/ 27 | /logs/ 28 | .mvn 29 | -------------------------------------------------------------------------------- /nicefish-user-center/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | .sts4-cache 12 | 13 | ### IntelliJ IDEA ### 14 | .idea 15 | *.iws 16 | *.iml 17 | *.ipr 18 | .mvn 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /build/ 23 | /nbbuild/ 24 | /dist/ 25 | /nbdist/ 26 | /.nb-gradle/ 27 | /logs/ 28 | .mvn 29 | -------------------------------------------------------------------------------- /nicefish-blog/src/test/java/com/fish/blog/NiceFishBlogApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.fish.blog; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class NiceFishBlogApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | } 16 | 17 | -------------------------------------------------------------------------------- /nicefish-zuul-server/src/test/java/com/fish/zuul/NiceFishZuulServerApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.fish.zuul; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class NiceFishZuulServerApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | 18 | -------------------------------------------------------------------------------- /nicefish-swagger2-api/src/test/java/com/fish/swagger2/NiceFishSwagger2ApiApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.fish.swagger2; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class NiceFishSwagger2ApiApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | 18 | -------------------------------------------------------------------------------- /nicefish-blog/src/main/java/com/fish/blog/service/IPostService.java: -------------------------------------------------------------------------------- 1 | package com.fish.blog.service; 2 | 3 | import com.fish.blog.entity.PostEntity; 4 | import org.springframework.data.domain.Page; 5 | import org.springframework.data.domain.Pageable; 6 | 7 | import java.util.List; 8 | 9 | public interface IPostService { 10 | Page getPostsPaging(Pageable var1); 11 | PostEntity getOne(Integer id); 12 | PostEntity savePost(PostEntity postEntity); 13 | void delPost(Integer id); 14 | Long countByUserId(Integer userId); 15 | List findByUserIdAndPaging(Integer userId, Integer start, Integer limit); 16 | } 17 | -------------------------------------------------------------------------------- /nicefish-swagger2-api/src/main/java/com/fish/swagger2/NiceFishSwagger2ApiApplication.java: -------------------------------------------------------------------------------- 1 | package com.fish.swagger2; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.context.annotation.ComponentScan; 6 | 7 | /** 8 | * Swagger2 文档总入口依赖所有其它Module,配置ComponentScan扫描范围为一级目录com.fish 9 | * @author 大漠穷秋 10 | */ 11 | @SpringBootApplication 12 | @ComponentScan(basePackages = {"com.fish"}) 13 | public class NiceFishSwagger2ApiApplication { 14 | public static void main(String[] args) { 15 | SpringApplication.run(NiceFishSwagger2ApiApplication.class, args); 16 | } 17 | 18 | } 19 | 20 | -------------------------------------------------------------------------------- /nicefish-user-center/src/main/java/com/fish/user/NiceFishUserCenterApplication.java: -------------------------------------------------------------------------------- 1 | package com.fish.user; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer; 7 | 8 | /** 9 | * @author 大漠穷秋 10 | */ 11 | @SpringBootApplication 12 | @EnableResourceServer 13 | @EnableDiscoveryClient 14 | public class NiceFishUserCenterApplication { 15 | public static void main(String[] args) { 16 | SpringApplication.run(NiceFishUserCenterApplication.class, args); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /nicefish-oauth2-jwt/src/main/java/com/fish/oauth/NiceFishOAuthApplication.java: -------------------------------------------------------------------------------- 1 | package com.fish.oauth; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.context.annotation.ComponentScan; 6 | import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer; 7 | 8 | /** 9 | * @author 大漠穷秋 10 | */ 11 | @SpringBootApplication 12 | @EnableAuthorizationServer 13 | @ComponentScan(basePackages = {"com.fish.oauth","com.fish.user"}) 14 | public class NiceFishOAuthApplication { 15 | public static void main(String[] args) { 16 | SpringApplication.run(NiceFishOAuthApplication.class, args); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /nicefish-user-center/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.fish 7 | nicefish-spring-cloud 8 | 0.0.1-SNAPSHOT 9 | 10 | com.fish 11 | nicefish-user-center 12 | 0.0.1-SNAPSHOT 13 | nicefish-user-center 14 | 用户中心,配合oauth实现JWT登录,用户相关的操作都在这里进行。 15 | jar 16 | 17 | -------------------------------------------------------------------------------- /nicefish-user-center/src/main/java/com/fish/user/config/WebAppConfig.java: -------------------------------------------------------------------------------- 1 | package com.fish.user.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.scheduling.TaskScheduler; 6 | import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; 7 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; 8 | 9 | @Configuration 10 | public class WebAppConfig extends WebMvcConfigurerAdapter { 11 | 12 | @Bean 13 | public TaskScheduler scheduledExecutorService() { 14 | ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler(); 15 | scheduler.setPoolSize(8); 16 | scheduler.setThreadNamePrefix("scheduled-thread-"); 17 | return scheduler; 18 | } 19 | } -------------------------------------------------------------------------------- /nicefish-user-center/src/test/java/com/fish/user/RoleRepositoryTests.java: -------------------------------------------------------------------------------- 1 | package com.fish.user; 2 | 3 | import com.fish.user.entity.RoleEntity; 4 | import com.fish.user.entity.RoleRepository; 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.boot.test.context.SpringBootTest; 9 | import org.springframework.test.context.junit4.SpringRunner; 10 | 11 | import java.util.List; 12 | 13 | @RunWith(SpringRunner.class) 14 | @SpringBootTest 15 | public class RoleRepositoryTests { 16 | @Autowired 17 | private RoleRepository roleRepository; 18 | 19 | @Test 20 | public void contextLoads() { 21 | //test find all 22 | List roleEntities=roleRepository.findAll(); 23 | System.out.println(roleEntities); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /nicefish-blog/src/main/java/com/fish/blog/repository/PostRepository.java: -------------------------------------------------------------------------------- 1 | package com.fish.blog.repository; 2 | 3 | import com.fish.blog.entity.PostEntity; 4 | import org.springframework.data.jpa.repository.Query; 5 | import org.springframework.data.repository.PagingAndSortingRepository; 6 | import org.springframework.stereotype.Repository; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * @author 大漠穷秋 12 | * @version 创建时间:2018-12-30 20:31 13 | */ 14 | @Repository 15 | public interface PostRepository extends PagingAndSortingRepository { 16 | @Query(value= 17 | "select * from blog_post where user_id=? order by post_time desc limit ?,?" 18 | ,nativeQuery = true) 19 | List findByUserIdAndPaging(Integer userId,Integer start,Integer limit); 20 | 21 | Long countByUserId(Integer userId); 22 | } 23 | -------------------------------------------------------------------------------- /nicefish-user-center/src/test/java/com/fish/user/PermissionRepositoryTests.java: -------------------------------------------------------------------------------- 1 | package com.fish.user; 2 | 3 | import com.fish.user.entity.PermissionEntity; 4 | import com.fish.user.entity.PermissionRepository; 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.boot.test.context.SpringBootTest; 9 | import org.springframework.test.context.junit4.SpringRunner; 10 | 11 | import java.util.List; 12 | 13 | @RunWith(SpringRunner.class) 14 | @SpringBootTest 15 | public class PermissionRepositoryTests { 16 | @Autowired 17 | private PermissionRepository permissionRepository; 18 | 19 | @Test 20 | public void contextLoads() { 21 | List permissionEntities=permissionRepository.findAll(); 22 | System.out.println(permissionEntities); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /nicefish-blog/src/main/java/com/fish/blog/util/ResponsePageImpl.java: -------------------------------------------------------------------------------- 1 | package com.fish.blog.util; 2 | 3 | import org.springframework.data.domain.PageImpl; 4 | import org.springframework.data.domain.Pageable; 5 | 6 | import java.io.Serializable; 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | /** 11 | * PageImpl没有默认的无参构造,会导致Jackson反序列化失败,继承一个空的子类来支持Jackson的反序列化 12 | * ref:https://jira.spring.io/browse/DATACMNS-1061 13 | * @param 14 | */ 15 | public class ResponsePageImpl extends PageImpl implements Serializable { 16 | 17 | public ResponsePageImpl () { 18 | super (new ArrayList<>()); 19 | } 20 | 21 | public ResponsePageImpl (List content) { 22 | super (content); 23 | } 24 | 25 | public ResponsePageImpl (List content, Pageable pageable, long total) { 26 | super (content, pageable, total); 27 | } 28 | } -------------------------------------------------------------------------------- /nicefish-swagger2-api/src/main/java/com/fish/swagger2/config/SwaggerConfig.java: -------------------------------------------------------------------------------- 1 | package com.fish.swagger2.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import springfox.documentation.builders.PathSelectors; 6 | import springfox.documentation.builders.RequestHandlerSelectors; 7 | import springfox.documentation.spi.DocumentationType; 8 | import springfox.documentation.spring.web.plugins.Docket; 9 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 10 | 11 | @Configuration 12 | @EnableSwagger2 13 | public class SwaggerConfig { 14 | @Bean 15 | public Docket api() { 16 | return new Docket(DocumentationType.SWAGGER_2) 17 | .select() 18 | .apis(RequestHandlerSelectors.any()) 19 | .paths(PathSelectors.any()) 20 | .build(); 21 | } 22 | } -------------------------------------------------------------------------------- /nicefish-zuul-server/src/main/java/com/fish/zuul/NiceFishZuulServerApplication.java: -------------------------------------------------------------------------------- 1 | package com.fish.zuul; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard; 7 | import org.springframework.cloud.netflix.turbine.EnableTurbine; 8 | import org.springframework.cloud.netflix.zuul.EnableZuulProxy; 9 | import org.springframework.context.annotation.ComponentScan; 10 | 11 | @EnableHystrixDashboard 12 | @EnableTurbine 13 | @EnableZuulProxy 14 | @EnableDiscoveryClient 15 | @SpringBootApplication 16 | @ComponentScan(basePackages = {"com.fish.zuul","com.fish.user"}) 17 | public class NiceFishZuulServerApplication { 18 | 19 | public static void main(String[] args) { 20 | SpringApplication.run(NiceFishZuulServerApplication.class, args); 21 | } 22 | } 23 | 24 | -------------------------------------------------------------------------------- /nicefish-blog/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.fish 7 | nicefish-spring-cloud 8 | 0.0.1-SNAPSHOT 9 | 10 | com.fish 11 | nicefish-blog 12 | 0.0.1-SNAPSHOT 13 | nicefish-blog 14 | Blog应用 15 | jar 16 | 17 | 18 | 19 | 20 | com.fish 21 | nicefish-user-center 22 | 0.0.1-SNAPSHOT 23 | compile 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /nicefish-oauth2-jwt/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | com.fish 6 | nicefish-oauth2-jwt 7 | 0.0.1-SNAPSHOT 8 | nicefish-oauth2-jwt 9 | 认证、授权和SSO相关的功能都在这里实现 10 | jar 11 | 12 | 13 | com.fish 14 | nicefish-spring-cloud 15 | 0.0.1-SNAPSHOT 16 | 17 | 18 | 19 | 20 | 21 | com.fish 22 | nicefish-user-center 23 | 0.0.1-SNAPSHOT 24 | compile 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /nicefish-oauth2-jwt/src/test/java/com/fish/oauth/NiceFishOAuthApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.fish.oauth; 2 | 3 | import com.fish.user.entity.UserEntity; 4 | import com.fish.user.entity.UserRepository; 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.boot.test.context.SpringBootTest; 9 | import org.springframework.test.context.junit4.SpringRunner; 10 | 11 | import java.util.List; 12 | 13 | @RunWith(SpringRunner.class) 14 | @SpringBootTest 15 | public class NiceFishOAuthApplicationTests { 16 | @Autowired 17 | private UserRepository userRepository; 18 | 19 | @Test 20 | public void baseTest() throws Exception { 21 | UserEntity userEntity=userRepository.findByEmail("william_j@gmail.com"); 22 | System.out.print(userEntity); 23 | 24 | // userEntity=userRepository.findByEmailAndPassword("william_j@gmail.com", new BCryptPasswordEncoder().encode("amaramar")); 25 | // System.out.print(userEntity); 26 | 27 | List authorities=userRepository.findAuthoritiesByEmail(userEntity.getEmail()); 28 | System.out.print(authorities); 29 | } 30 | } -------------------------------------------------------------------------------- /nicefish-blog/src/main/java/com/fish/blog/NiceFishBlogApplication.java: -------------------------------------------------------------------------------- 1 | package com.fish.blog; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.boot.autoconfigure.domain.EntityScan; 6 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 7 | import org.springframework.context.annotation.ComponentScan; 8 | import org.springframework.data.jpa.repository.config.EnableJpaRepositories; 9 | import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer; 10 | 11 | /** 12 | * blog模块会依赖user-center模块中的FishJwtTokenConverter、SecurityConfig等配置项和Class, 13 | * 所以这里加了@ComponentScan注解,扫描blog和user两个二级目录 14 | * @author 大漠穷秋 15 | */ 16 | @SpringBootApplication 17 | @EnableResourceServer 18 | @EnableDiscoveryClient 19 | @EnableJpaRepositories(basePackages ={"com.fish.blog","com.fish.user"} ) 20 | @EntityScan(basePackages = {"com.fish.blog","com.fish.user"}) 21 | @ComponentScan(basePackages = {"com.fish.blog","com.fish.user"}) 22 | public class NiceFishBlogApplication { 23 | 24 | public static void main(String[] args) { 25 | SpringApplication.run(NiceFishBlogApplication.class, args); 26 | } 27 | 28 | } -------------------------------------------------------------------------------- /nicefish-blog/src/main/java/com/fish/blog/repository/CommentRepository.java: -------------------------------------------------------------------------------- 1 | package com.fish.blog.repository; 2 | 3 | import com.fish.blog.entity.CommentEntity; 4 | import org.springframework.data.domain.Page; 5 | import org.springframework.data.domain.Pageable; 6 | import org.springframework.data.jpa.repository.JpaRepository; 7 | import org.springframework.data.jpa.repository.Query; 8 | import org.springframework.stereotype.Repository; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | * @author 大漠穷秋 14 | * @version 创建时间:2018-12-30 20:31 15 | */ 16 | @Repository 17 | public interface CommentRepository extends JpaRepository { 18 | @Query(value = "SELECT * FROM blog_comment WHERE post_id = ?1 ORDER BY ?#{#pageable}", 19 | countQuery = "SELECT count(*) FROM blog_comment WHERE post_id = ?1 ORDER BY ?#{#pageable}", 20 | nativeQuery = true) 21 | Page findByPostId(String postId,Pageable pageable); 22 | 23 | @Query(value= 24 | "select * from blog_comment where user_id=? order by comment_time desc limit ?,?" 25 | ,nativeQuery = true) 26 | List findCommentByUserIdAndPaging(Integer userId, Integer start, Integer limit); 27 | 28 | Long countByUserId(Integer userId); 29 | } -------------------------------------------------------------------------------- /nicefish-user-center/src/main/java/com/fish/user/util/AjaxResponseEntity.java: -------------------------------------------------------------------------------- 1 | package com.fish.user.util; 2 | 3 | /** 4 | * @author 大漠穷秋 5 | * @version 创建时间:2019-01-01 11:53 6 | */ 7 | public class AjaxResponseEntity { 8 | private boolean success; 9 | private String msg; 10 | private Object data; 11 | 12 | public AjaxResponseEntity(){ 13 | 14 | } 15 | 16 | public AjaxResponseEntity(boolean success){ 17 | this.success=success; 18 | } 19 | 20 | public AjaxResponseEntity(boolean success,String msg){ 21 | this.success=success; 22 | this.msg=msg; 23 | } 24 | 25 | public AjaxResponseEntity(boolean success,String msg,Object data){ 26 | this.success=success; 27 | this.msg=msg; 28 | this.data=data; 29 | } 30 | 31 | public boolean isSuccess() { 32 | return success; 33 | } 34 | 35 | public void setSuccess(boolean success) { 36 | this.success = success; 37 | } 38 | 39 | public String getMsg() { 40 | return msg; 41 | } 42 | 43 | public void setMsg(String msg) { 44 | this.msg = msg; 45 | } 46 | 47 | public Object getData() { 48 | return data; 49 | } 50 | 51 | public void setData(Object data) { 52 | this.data = data; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /nicefish-zuul-server/src/main/java/com/fish/zuul/config/HystrixConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.fish.zuul.config; 2 | 3 | import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet; 4 | import org.springframework.boot.web.servlet.ServletRegistrationBean; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | 8 | @Configuration 9 | public class HystrixConfiguration { 10 | 11 | @Bean(name = "hystrixRegistrationBean") 12 | public ServletRegistrationBean servletRegistrationBean() { 13 | ServletRegistrationBean registration = new ServletRegistrationBean( 14 | new HystrixMetricsStreamServlet(), "/hystrix.stream"); 15 | registration.setName("hystrixServlet"); 16 | registration.setLoadOnStartup(1); 17 | return registration; 18 | } 19 | 20 | @Bean(name = "hystrixForTurbineRegistrationBean") 21 | public ServletRegistrationBean servletTurbineRegistrationBean() { 22 | ServletRegistrationBean registration = new ServletRegistrationBean( 23 | new HystrixMetricsStreamServlet(), "/actuator/hystrix.stream"); 24 | registration.setName("hystrixForTurbineServlet"); 25 | registration.setLoadOnStartup(1); 26 | return registration; 27 | } 28 | } -------------------------------------------------------------------------------- /nicefish-user-center/src/main/java/com/fish/user/entity/PermissionEntity.java: -------------------------------------------------------------------------------- 1 | package com.fish.user.entity; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | 5 | import javax.persistence.*; 6 | import java.util.Set; 7 | 8 | /** 9 | * @author 大漠穷秋 10 | * @version 创建时间:2018-12-30 21:53 11 | */ 12 | @Entity 13 | @Table(name="auth_permission") 14 | public class PermissionEntity { 15 | @Id 16 | @GeneratedValue(strategy = GenerationType.IDENTITY) 17 | @Column(name="id") 18 | private Integer id; 19 | @Column(name="PermissionName") 20 | private String permissionName; 21 | @ManyToMany(cascade = CascadeType.PERSIST,fetch = FetchType.LAZY) 22 | @JoinTable(name = "auth_role_permission", 23 | joinColumns = {@JoinColumn(name = "permission_id", referencedColumnName = "id")}, 24 | inverseJoinColumns = {@JoinColumn(name = "role_id", referencedColumnName = "id")}) 25 | @JsonIgnore 26 | private Set roles; 27 | 28 | public Integer getId() { 29 | return id; 30 | } 31 | 32 | public void setId(Integer id) { 33 | this.id = id; 34 | } 35 | 36 | public String getPermissionName() { 37 | return permissionName; 38 | } 39 | 40 | public void setPermissionName(String permissionName) { 41 | this.permissionName = permissionName; 42 | } 43 | 44 | public Set getRoles() { 45 | return roles; 46 | } 47 | 48 | public void setRoles(Set roles) { 49 | this.roles = roles; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /nicefish-oauth2-jwt/src/main/java/com/fish/oauth/service/CustomUserDetailsService.java: -------------------------------------------------------------------------------- 1 | package com.fish.oauth.service; 2 | 3 | import com.fish.oauth.entity.CustomUserEntity; 4 | import com.fish.user.entity.UserEntity; 5 | import com.fish.user.entity.UserRepository; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.security.core.authority.SimpleGrantedAuthority; 8 | import org.springframework.security.core.userdetails.UserDetails; 9 | import org.springframework.security.core.userdetails.UserDetailsService; 10 | import org.springframework.security.core.userdetails.UsernameNotFoundException; 11 | import org.springframework.stereotype.Service; 12 | 13 | import java.util.List; 14 | 15 | /** 16 | * 自定义用户详情服务,目的是在用户详情里面增加自定义字段,这些字段会被存储到JWT的Token里面。 17 | * @see com.fish.oauth.config.OAuthWebSecurityConfig 里面会利用此服务来查询数据库中的用户详情。 18 | * @author 大漠穷秋 19 | */ 20 | @Service 21 | public class CustomUserDetailsService implements UserDetailsService { 22 | @Autowired 23 | UserRepository userRepository; 24 | 25 | @Override 26 | public UserDetails loadUserByUsername(String userName) throws UsernameNotFoundException { 27 | UserEntity userEntity = userRepository.findByEmail(userName); 28 | 29 | List authorities=userRepository.findAuthoritiesByEmail(userName); 30 | for(String authority:authorities){ 31 | authority="ROLE_"+authority; 32 | userEntity.getGrantedAuthoritiesList().add(new SimpleGrantedAuthority(authority)); 33 | } 34 | 35 | CustomUserEntity customUser = new CustomUserEntity(userEntity); 36 | return customUser; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /nicefish-user-center/src/main/java/com/fish/user/entity/UserRepository.java: -------------------------------------------------------------------------------- 1 | package com.fish.user.entity; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | import org.springframework.data.jpa.repository.Query; 5 | 6 | import java.util.List; 7 | /** 8 | * @author 大漠穷秋 9 | */ 10 | public interface UserRepository extends JpaRepository { 11 | UserEntity findByEmail(String email); 12 | UserEntity findByMobile(String mobile); 13 | UserEntity findByEmailAndPassword(String email, String password); 14 | UserEntity findByMobileAndPassword(String mobile, String password); 15 | 16 | void deleteByEmail(String email); 17 | 18 | /** 19 | * User-->Role-->Permission 之间有两层映射,JPQL写起来比较麻烦,这里直接一条原生SQL查出User对应的Permission 20 | * @param email 21 | * @return 22 | */ 23 | @Query(value="select distinct p.permission_name " + 24 | "from auth_user u " + 25 | "inner join auth_user_role r_u on u.id=r_u.user_id " + 26 | "inner join auth_role r on r_u.role_id=r.id " + 27 | "inner join auth_role_permission r_p on r_p.role_id=r.id " + 28 | "inner join auth_permission p on p.id=r_p.permission_id where u.email=?" 29 | ,nativeQuery = true) 30 | List findAuthoritiesByEmail(String email); 31 | 32 | @Query(value= 33 | "select * from auth_user order by create_time desc limit ?,?" 34 | ,nativeQuery = true) 35 | List findByPageing(Integer start,Integer limit); 36 | 37 | @Query(value="select count(id) from auth_user" 38 | ,nativeQuery = true) 39 | Long countAllRows(); 40 | } -------------------------------------------------------------------------------- /nicefish-user-center/src/main/java/com/fish/user/controller/PermissionController.java: -------------------------------------------------------------------------------- 1 | package com.fish.user.controller; 2 | 3 | import com.fish.user.entity.PermissionRepository; 4 | import com.fish.user.entity.RoleRepository; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.http.HttpStatus; 7 | import org.springframework.http.ResponseEntity; 8 | import org.springframework.web.bind.annotation.*; 9 | 10 | import java.util.ArrayList; 11 | /** 12 | * @author 大漠穷秋 13 | */ 14 | @RestController 15 | @RequestMapping("/users") 16 | public class PermissionController { 17 | 18 | @Autowired 19 | PermissionRepository permissionRepository; 20 | 21 | @Autowired 22 | RoleRepository roleRepository; 23 | 24 | @RequestMapping(value = "/permissions", method = RequestMethod.GET) 25 | public ResponseEntity getListOfPermissions() { 26 | return new ResponseEntity(permissionRepository.findAll(), HttpStatus.OK); 27 | } 28 | 29 | @RequestMapping(value = "/roles/{id}/permissions", method = RequestMethod.GET) 30 | public ResponseEntity viewPermissionsByRole(@PathVariable("id") Integer roleId) { 31 | return new ResponseEntity<>(roleRepository.findOne(roleId), HttpStatus.OK); 32 | } 33 | 34 | @RequestMapping(value = "/roles/{id}/permissions", method = RequestMethod.PUT) 35 | public ResponseEntity assignPermissions2Role(@PathVariable("id") Integer roleId, @RequestBody ArrayList permissionsList) { 36 | //TODO:这里需要重新实现 37 | return new ResponseEntity<>("Permissions are assigned to role successfully", HttpStatus.OK); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /nicefish-zuul-server/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.fish 7 | nicefish-spring-cloud 8 | 0.0.1-SNAPSHOT 9 | 10 | com.fish 11 | nicefish-zuul-server 12 | 0.0.1-SNAPSHOT 13 | nicefish-zuul-server 14 | API网关zuul的配置 15 | jar 16 | 17 | 18 | 19 | 20 | com.fish 21 | nicefish-user-center 22 | 0.0.1-SNAPSHOT 23 | compile 24 | 25 | 26 | 27 | org.springframework.cloud 28 | spring-cloud-starter-zuul 29 | 30 | 31 | org.springframework.cloud 32 | spring-cloud-starter-netflix-hystrix-dashboard 33 | 34 | 35 | org.springframework.cloud 36 | spring-cloud-netflix-turbine 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /nicefish-zuul-server/src/main/java/com/fish/zuul/filter/FishCorsFilter.java: -------------------------------------------------------------------------------- 1 | package com.fish.zuul.filter; 2 | 3 | import org.springframework.core.Ordered; 4 | import org.springframework.core.annotation.Order; 5 | import org.springframework.http.HttpMethod; 6 | import org.springframework.stereotype.Component; 7 | 8 | import javax.servlet.*; 9 | import javax.servlet.http.HttpServletRequest; 10 | import javax.servlet.http.HttpServletResponse; 11 | import java.io.IOException; 12 | 13 | /** 14 | * 由于后端服务会分布在不同的IP和端口上,前端代码在做测试时会进行跨域请求,这个Filter用来支持跨域的情况。 15 | * @author 大漠穷秋 16 | */ 17 | @Component 18 | @Order(Ordered.HIGHEST_PRECEDENCE) 19 | public class FishCorsFilter implements Filter { 20 | @Override 21 | public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { 22 | final HttpServletResponse response = (HttpServletResponse) res; 23 | //Note:这里可以加上你自己特定的协议头 24 | response.setHeader("Access-Control-Allow-Origin", "*"); 25 | response.setHeader("Access-Control-Allow-Methods", "POST, PUT, GET, OPTIONS, DELETE"); 26 | response.setHeader("Access-Control-Allow-Headers", "Authorization, Content-Type"); 27 | response.setHeader("Access-Control-Max-Age", "3600"); 28 | if (HttpMethod.OPTIONS.name().equalsIgnoreCase(((HttpServletRequest) req).getMethod())) { 29 | response.setStatus(HttpServletResponse.SC_OK); 30 | } else { 31 | chain.doFilter(req, res); 32 | } 33 | } 34 | 35 | @Override 36 | public void destroy() { 37 | } 38 | 39 | @Override 40 | public void init(FilterConfig config) throws ServletException { 41 | } 42 | } -------------------------------------------------------------------------------- /nicefish-user-center/src/main/java/com/fish/user/controller/RoleController.java: -------------------------------------------------------------------------------- 1 | package com.fish.user.controller; 2 | 3 | import com.fish.user.entity.RoleEntity; 4 | import com.fish.user.entity.RoleRepository; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.http.HttpStatus; 7 | import org.springframework.http.ResponseEntity; 8 | import org.springframework.web.bind.annotation.*; 9 | /** 10 | * @author 大漠穷秋 11 | */ 12 | @RestController 13 | @RequestMapping("/users") 14 | public class RoleController { 15 | @Autowired 16 | RoleRepository roleRepository; 17 | 18 | @RequestMapping(value = "/roles", method = RequestMethod.GET) 19 | public ResponseEntity getListOfRoles() { 20 | return new ResponseEntity(roleRepository.findAll(), HttpStatus.OK); 21 | } 22 | 23 | @RequestMapping(value = "/roles/{id}", method = RequestMethod.DELETE) 24 | public ResponseEntity deleteRole(@PathVariable("id") Integer roleId) { 25 | roleRepository.delete(roleId); 26 | return new ResponseEntity("Role deleted successfully", HttpStatus.OK); 27 | } 28 | 29 | @RequestMapping(value = "/roles/{id}", method = RequestMethod.PUT) 30 | public ResponseEntity updateRole(@PathVariable("id") Integer roleId, @RequestBody RoleEntity roleEntity) { 31 | roleRepository.save(roleEntity); 32 | return new ResponseEntity("Role updated successfully", HttpStatus.OK); 33 | } 34 | 35 | @RequestMapping(value = "/roles", method = RequestMethod.POST) 36 | public ResponseEntity createRole(@RequestBody RoleEntity roleEntity) { 37 | roleRepository.save(roleEntity); 38 | return new ResponseEntity("Role created successfully", HttpStatus.OK); 39 | } 40 | } -------------------------------------------------------------------------------- /nicefish-blog/src/main/java/com/fish/blog/service/impl/PostServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.fish.blog.service.impl; 2 | 3 | import com.fish.blog.entity.PostEntity; 4 | import com.fish.blog.repository.PostRepository; 5 | import com.fish.blog.service.IPostService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.cache.annotation.CacheEvict; 8 | import org.springframework.cache.annotation.Cacheable; 9 | import org.springframework.data.domain.Page; 10 | import org.springframework.data.domain.Pageable; 11 | import org.springframework.stereotype.Service; 12 | 13 | import java.util.List; 14 | 15 | 16 | @Service 17 | public class PostServiceImpl implements IPostService { 18 | @Autowired 19 | private PostRepository postRepository; 20 | 21 | @Override 22 | @Cacheable(value="posts",key ="T(String).valueOf(#var1.pageNumber).concat('-').concat(#var1.pageSize)", unless="#result==null") 23 | public Page getPostsPaging(Pageable var1) { 24 | return postRepository.findAll(var1); 25 | } 26 | 27 | @Override 28 | @Cacheable(value = "post-detail",key = "T(String).valueOf(#id)", unless="#result==null") 29 | public PostEntity getOne(Integer id){ 30 | return (PostEntity)postRepository.findOne(id); 31 | } 32 | 33 | //TODO:重新设计posts这个缓存的KV结构,避免清除整个缓存 34 | @Override 35 | @CacheEvict(value = "posts",allEntries = true) 36 | public PostEntity savePost(PostEntity postEntity) { 37 | return postRepository.save(postEntity); 38 | } 39 | 40 | @Override 41 | @CacheEvict(value = "posts",allEntries = true) 42 | public void delPost(Integer id) { 43 | postRepository.delete(id); 44 | } 45 | 46 | @Override 47 | public Long countByUserId(Integer userId) { 48 | return postRepository.countByUserId(userId); 49 | } 50 | 51 | @Override 52 | public List findByUserIdAndPaging(Integer userId, Integer start, Integer limit) { 53 | return postRepository.findByUserIdAndPaging(userId,start,limit); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /nicefish-user-center/src/main/java/com/fish/user/entity/RoleEntity.java: -------------------------------------------------------------------------------- 1 | package com.fish.user.entity; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | 5 | import javax.persistence.*; 6 | import java.util.Set; 7 | 8 | /** 9 | * @author 大漠穷秋 10 | * @version 创建时间:2018-12-30 19:55 11 | */ 12 | @Entity 13 | @Table(name = "auth_role") 14 | public class RoleEntity { 15 | @Id 16 | @Column(name = "id") 17 | @GeneratedValue(strategy = GenerationType.IDENTITY) 18 | private Integer id; 19 | @Column(name="RoleName") 20 | private String roleName; 21 | @ManyToMany(cascade = CascadeType.PERSIST,fetch = FetchType.LAZY) 22 | @JoinTable(name = "auth_user_role", 23 | joinColumns = {@JoinColumn(name = "role_id", referencedColumnName = "id")}, 24 | inverseJoinColumns = {@JoinColumn(name = "user_id", referencedColumnName = "id")}) 25 | @JsonIgnore 26 | private Set users; 27 | 28 | @ManyToMany(cascade = CascadeType.PERSIST,fetch = FetchType.LAZY) 29 | @JoinTable(name = "auth_role_permission", 30 | joinColumns = {@JoinColumn(name = "role_id", referencedColumnName = "id")}, 31 | inverseJoinColumns = {@JoinColumn(name = "permission_id", referencedColumnName = "id")}) 32 | @JsonIgnore 33 | private Set permissions; 34 | 35 | public Integer getId() { 36 | return id; 37 | } 38 | 39 | public void setId(Integer id) { 40 | this.id = id; 41 | } 42 | 43 | public String getRoleName() { 44 | return roleName; 45 | } 46 | 47 | public void setRoleName(String roleName) { 48 | this.roleName = roleName; 49 | } 50 | 51 | public Set getUsers() { 52 | return users; 53 | } 54 | 55 | public void setUsers(Set users) { 56 | this.users = users; 57 | } 58 | 59 | public Set getPermissions() { 60 | return permissions; 61 | } 62 | 63 | public void setPermissions(Set permissions) { 64 | this.permissions = permissions; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /nicefish-oauth2-jwt/src/main/java/com/fish/oauth/entity/CustomUserEntity.java: -------------------------------------------------------------------------------- 1 | package com.fish.oauth.entity; 2 | 3 | import com.fish.user.entity.UserEntity; 4 | import org.springframework.security.core.userdetails.User; 5 | 6 | /** 7 | * User包装类,用来包装从数据库获得的实体类,同时继承SpringSecurity原生的User类。 8 | * 包装的目的是为了向SpringSecurity原生的User类上增加一些属性。 9 | * 10 | * @author 大漠穷秋 11 | */ 12 | public class CustomUserEntity extends User { 13 | private Integer id; 14 | private String firstName; 15 | private String lastName; 16 | private String mobile; 17 | private String country; 18 | private String email; 19 | 20 | public CustomUserEntity(UserEntity user) { 21 | super(user.getEmail(), user.getPassword(), user.getGrantedAuthoritiesList()); 22 | this.id = user.getId(); 23 | this.firstName = user.getFirstName(); 24 | this.lastName = user.getLastName(); 25 | this.mobile = user.getMobile(); 26 | this.country = user.getCountry(); 27 | this.email=user.getEmail(); 28 | } 29 | 30 | public String getEmail() { 31 | return email; 32 | } 33 | 34 | public void setEmail(String email) { 35 | this.email = email; 36 | } 37 | 38 | public Integer getId() { 39 | return id; 40 | } 41 | 42 | public void setId(Integer id) { 43 | this.id = id; 44 | } 45 | 46 | public String getFirstName() { 47 | return firstName; 48 | } 49 | 50 | public void setFirstName(String firstName) { 51 | this.firstName = firstName; 52 | } 53 | 54 | public String getLastName() { 55 | return lastName; 56 | } 57 | 58 | public void setLastName(String lastName) { 59 | this.lastName = lastName; 60 | } 61 | 62 | public String getMobile() { 63 | return mobile; 64 | } 65 | 66 | public void setMobile(String mobile) { 67 | this.mobile = mobile; 68 | } 69 | 70 | public String getCountry() { 71 | return country; 72 | } 73 | 74 | public void setCountry(String country) { 75 | this.country = country; 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /nicefish-oauth2-jwt/src/main/java/com/fish/oauth/util/JwtAccessTokenConverterEnhancer.java: -------------------------------------------------------------------------------- 1 | package com.fish.oauth.util; 2 | 3 | import com.fish.oauth.entity.CustomUserEntity; 4 | import org.springframework.security.oauth2.common.DefaultOAuth2AccessToken; 5 | import org.springframework.security.oauth2.common.OAuth2AccessToken; 6 | import org.springframework.security.oauth2.provider.OAuth2Authentication; 7 | import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter; 8 | 9 | import java.util.LinkedHashMap; 10 | import java.util.Map; 11 | 12 | /** 13 | * 自定义 JWT Token 转换器,把用户名、邮箱、手机号等信息存到Token里面,OAuth2Config 里面会使用这个这个自定义的转换器来生成Token。 14 | * 使用者在拿到JWT的Token时可以直接从里面解析出用户基本资料和对应的权限。 15 | * Spring Security 内置的 UserDetails 只带有username,password和authorities这3个基本的字段。 16 | * @see org.springframework.security.core.userdetails.UserDetails 17 | * @see com.fish.oauth.config.OAuth2Config 18 | * @author 大漠穷秋 19 | */ 20 | public class JwtAccessTokenConverterEnhancer extends JwtAccessTokenConverter { 21 | @Override 22 | public OAuth2AccessToken enhance(OAuth2AccessToken accessToken, OAuth2Authentication authentication) { 23 | CustomUserEntity user = (CustomUserEntity) authentication.getPrincipal(); 24 | 25 | Map info = new LinkedHashMap<>(accessToken.getAdditionalInformation()); 26 | if (user.getId() != null) 27 | info.put("id", user.getId()); 28 | if (user.getFirstName() != null) 29 | info.put("first_name", user.getFirstName()); 30 | if (user.getLastName() != null) 31 | info.put("last_name", user.getLastName()); 32 | if (user.getCountry() != null) 33 | info.put("country", user.getCountry()); 34 | if (user.getMobile() != null) 35 | info.put("mobile", user.getMobile()); 36 | if(user.getEmail()!=null) 37 | info.put("email",user.getEmail()); 38 | 39 | DefaultOAuth2AccessToken customAccessToken = new DefaultOAuth2AccessToken(accessToken); 40 | customAccessToken.setAdditionalInformation(info); 41 | return super.enhance(customAccessToken, authentication); 42 | } 43 | } -------------------------------------------------------------------------------- /config/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | ${CONSOLE_LOG_PATTERN} 16 | UTF-8 17 | 18 | 19 | 20 | 21 | 22 | ${FILE_PATH}-${FILE_NAME_PATTERN} 23 | 1 24 | 10MB 25 | 20MB 26 | 27 | 28 | ${FILE_LOG_PATTERN} 29 | UTF-8 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /nicefish-swagger2-api/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.fish 7 | nicefish-spring-cloud 8 | 0.0.1-SNAPSHOT 9 | 10 | com.fish 11 | nicefish-swagger2-api 12 | 0.0.1-SNAPSHOT 13 | nicefish-swagger2-api 14 | Swagger文档入口 15 | jar 16 | 17 | 18 | 19 | 20 | io.springfox 21 | springfox-swagger2 22 | 2.8.0 23 | 24 | 25 | io.springfox 26 | springfox-swagger-ui 27 | 2.8.0 28 | 29 | 30 | 31 | 32 | com.fish 33 | nicefish-user-center 34 | 0.0.1-SNAPSHOT 35 | compile 36 | 37 | 38 | com.fish 39 | nicefish-blog 40 | 0.0.1-SNAPSHOT 41 | compile 42 | 43 | 44 | com.fish 45 | nicefish-oauth2-jwt 46 | 0.0.1-SNAPSHOT 47 | compile 48 | 49 | 50 | com.fish 51 | nicefish-zuul-server 52 | 0.0.1-SNAPSHOT 53 | compile 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /nicefish-user-center/src/test/java/com/fish/user/UserRepositoryTests.java: -------------------------------------------------------------------------------- 1 | package com.fish.user; 2 | 3 | import com.fish.user.entity.UserEntity; 4 | import com.fish.user.entity.UserRepository; 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.boot.test.context.SpringBootTest; 9 | import org.springframework.test.context.junit4.SpringRunner; 10 | 11 | import java.util.List; 12 | 13 | @RunWith(SpringRunner.class) 14 | @SpringBootTest 15 | public class UserRepositoryTests { 16 | @Autowired 17 | private UserRepository userRepository; 18 | 19 | @Test 20 | public void contextLoads() { 21 | //test find all 22 | // Gson gson=new Gson(); 23 | List users=userRepository.findAll(); 24 | // System.out.println(gson.toJson(users)); 25 | 26 | //单独Insert User 27 | UserEntity user1=new UserEntity(); 28 | // user1.setEmail("test-"+ UUID.randomUUID().toString()); 29 | // user1.setCountry("test"); 30 | // user1.setFirstName("test"); 31 | // user1.setLastName("test"); 32 | // user1.setMobile("test"); 33 | // user1.setPassword("test"); 34 | // userRepository.save(user1); 35 | 36 | //User 和 Role 级联insert 37 | UserEntity user2=new UserEntity(); 38 | // user.setEmail("test"); 39 | // user.setCountry("test"); 40 | // user.setFirstName("test"); 41 | // user.setLastName("test"); 42 | // user.setMobile("test"); 43 | // user.setPassword("test"); 44 | // RoleEntity roleEntity=new RoleEntity(); 45 | // roleEntity.setRoleName("test-role-"+ UUID.randomUUID().toString()); 46 | // Set roles=new HashSet(); 47 | // roles.add(roleEntity); 48 | // user.setRoles(roles); 49 | // userRepository.save(user); 50 | 51 | //test delete 52 | // userRepository.delete(15); 53 | 54 | //test update 55 | // user=new UserEntity(); 56 | // user.setId(17); 57 | // user.setEmail("test"); 58 | // user.setCountry("test"); 59 | // user.setFirstName("test"); 60 | // user.setLastName("test"); 61 | // user.setMobile("test"); 62 | // user.setPassword("test"); 63 | // RoleEntity roleEntit2=new RoleEntity(); 64 | // roleEntit2.setId(4); 65 | // roleEntit2.setRoleName("test-role-64e696f5-5ea3-42cb-bd8c-a02977cdc9cc"); 66 | // Set roles2=new HashSet(); 67 | // roles2.add(roleEntit2); 68 | // user.setRoles(roles2); 69 | // userRepository.save(user); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /nicefish-blog/src/main/java/com/fish/blog/config/RedisConfig.java: -------------------------------------------------------------------------------- 1 | package com.fish.blog.config; 2 | 3 | import org.springframework.cache.CacheManager; 4 | import org.springframework.cache.annotation.CachingConfigurerSupport; 5 | import org.springframework.cache.annotation.EnableCaching; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.Configuration; 8 | import org.springframework.data.redis.cache.RedisCacheManager; 9 | import org.springframework.data.redis.connection.RedisConnectionFactory; 10 | import org.springframework.data.redis.core.RedisTemplate; 11 | import org.springframework.data.redis.core.StringRedisTemplate; 12 | import org.springframework.data.redis.serializer.JdkSerializationRedisSerializer; 13 | 14 | @Configuration 15 | @EnableCaching 16 | public class RedisConfig extends CachingConfigurerSupport { 17 | // @Bean 18 | // public KeyGenerator keyGenerator() { 19 | // return new KeyGenerator(){ 20 | // @Override 21 | // public Object generate(Object target, java.lang.reflect.Method method, Object... params) { 22 | // StringBuffer sb = new StringBuffer(); 23 | // sb.append(target.getClass().getName()); 24 | // sb.append(method.getName()); 25 | // for(Object obj:params){ 26 | // sb.append(obj.toString()); 27 | // } 28 | // return sb.toString(); 29 | // } 30 | // }; 31 | // } 32 | 33 | @Bean 34 | public CacheManager cacheManager(@SuppressWarnings("rawtypes") RedisTemplate redisTemplate) { 35 | RedisCacheManager cacheManager = new RedisCacheManager(redisTemplate); 36 | cacheManager.setDefaultExpiration(10000); 37 | return cacheManager; 38 | } 39 | 40 | @Bean 41 | public RedisTemplate redisTemplate(RedisConnectionFactory factory){ 42 | StringRedisTemplate template = new StringRedisTemplate(factory); 43 | this.setSerializer(template); 44 | template.afterPropertiesSet(); 45 | return template; 46 | } 47 | 48 | private void setSerializer(StringRedisTemplate template){ 49 | //备注:这里不能使用Jackson2JsonRedisSerializer,因为PageImpl这个实现类没有无参构造,Jackson无法反序列化 50 | template.setHashKeySerializer(new JdkSerializationRedisSerializer()); 51 | template.setHashValueSerializer(new JdkSerializationRedisSerializer()); 52 | template.setKeySerializer(new JdkSerializationRedisSerializer()); 53 | template.setValueSerializer(new JdkSerializationRedisSerializer()); 54 | } 55 | } -------------------------------------------------------------------------------- /nicefish-oauth2-jwt/src/main/java/com/fish/oauth/config/OAuthWebSecurityConfig.java: -------------------------------------------------------------------------------- 1 | package com.fish.oauth.config; 2 | 3 | import com.fish.oauth.service.CustomUserDetailsService; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.http.HttpMethod; 8 | import org.springframework.security.authentication.AuthenticationManager; 9 | import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; 10 | import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; 11 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; 12 | import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; 13 | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; 14 | import org.springframework.security.config.http.SessionCreationPolicy; 15 | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; 16 | 17 | /** 18 | * Spring Security 配置 19 | * @author 大漠穷秋 20 | */ 21 | @Configuration 22 | @EnableWebSecurity 23 | @EnableGlobalMethodSecurity(prePostEnabled = true) 24 | public class OAuthWebSecurityConfig extends WebSecurityConfigurerAdapter { 25 | @Autowired 26 | CustomUserDetailsService customDetailsService; 27 | 28 | @Override 29 | @Autowired 30 | protected void configure(AuthenticationManagerBuilder authenticationManagerBuilder) throws Exception { 31 | authenticationManagerBuilder.userDetailsService(customDetailsService).passwordEncoder(new BCryptPasswordEncoder()); 32 | } 33 | 34 | @Override 35 | @Bean 36 | public AuthenticationManager authenticationManagerBean() throws Exception { 37 | return super.authenticationManagerBean(); 38 | } 39 | 40 | @Override 41 | protected void configure(HttpSecurity httpSecurity) throws Exception { 42 | // @formatter:off 43 | httpSecurity.authorizeRequests() 44 | .antMatchers(HttpMethod.OPTIONS).permitAll() 45 | .antMatchers("/login").permitAll() 46 | .antMatchers("/oauth/token").permitAll() 47 | .anyRequest().authenticated() 48 | .and().sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS) 49 | .and().formLogin().permitAll() 50 | .and().logout().permitAll() 51 | .and().csrf().disable(); 52 | // @formatter:on 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /nicefish-zuul-server/src/main/java/com/fish/zuul/provider/ApiFallbackProvider.java: -------------------------------------------------------------------------------- 1 | package com.fish.zuul.provider; 2 | 3 | import com.netflix.hystrix.exception.HystrixTimeoutException; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.cloud.netflix.zuul.filters.route.FallbackProvider; 6 | import org.springframework.http.HttpHeaders; 7 | import org.springframework.http.HttpStatus; 8 | import org.springframework.http.MediaType; 9 | import org.springframework.http.client.ClientHttpResponse; 10 | import org.springframework.stereotype.Component; 11 | 12 | import java.io.ByteArrayInputStream; 13 | import java.io.IOException; 14 | import java.io.InputStream; 15 | 16 | @Slf4j 17 | @Component 18 | public class ApiFallbackProvider implements FallbackProvider { 19 | @Override 20 | public String getRoute() { 21 | return "*"; 22 | } 23 | 24 | @Override 25 | public ClientHttpResponse fallbackResponse() { 26 | return null; 27 | } 28 | 29 | @Override 30 | public ClientHttpResponse fallbackResponse(Throwable cause) { 31 | log.debug(getRoute()+cause.getMessage()); 32 | String message = ""; 33 | if (cause instanceof HystrixTimeoutException) { 34 | message = "Timeout"; 35 | } else { 36 | message = "Service exception"; 37 | } 38 | return fallbackResponse(message); 39 | } 40 | 41 | public ClientHttpResponse fallbackResponse(String message) { 42 | return new ClientHttpResponse() { 43 | @Override 44 | public HttpStatus getStatusCode() throws IOException { 45 | return HttpStatus.OK; 46 | } 47 | 48 | @Override 49 | public int getRawStatusCode() throws IOException { 50 | return 200; 51 | } 52 | 53 | @Override 54 | public String getStatusText() throws IOException { 55 | return "OK"; 56 | } 57 | 58 | @Override 59 | public void close() { 60 | 61 | } 62 | 63 | @Override 64 | public InputStream getBody() throws IOException { 65 | String bodyText = String.format("{\"code\": 999,\"message\": \"Service unavailable:%s\"}", message); 66 | return new ByteArrayInputStream(bodyText.getBytes()); 67 | } 68 | 69 | @Override 70 | public HttpHeaders getHeaders() { 71 | HttpHeaders headers = new HttpHeaders(); 72 | headers.setContentType(MediaType.APPLICATION_JSON); 73 | return headers; 74 | } 75 | }; 76 | } 77 | } -------------------------------------------------------------------------------- /nicefish-blog/src/main/java/com/fish/blog/controller/CommentController.java: -------------------------------------------------------------------------------- 1 | package com.fish.blog.controller; 2 | 3 | import com.fish.blog.entity.CommentEntity; 4 | import com.fish.blog.repository.CommentRepository; 5 | import com.fish.user.util.AjaxResponseEntity; 6 | import lombok.extern.slf4j.Slf4j; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.data.domain.Page; 9 | import org.springframework.data.domain.PageRequest; 10 | import org.springframework.http.HttpStatus; 11 | import org.springframework.http.ResponseEntity; 12 | import org.springframework.security.access.prepost.PreAuthorize; 13 | import org.springframework.web.bind.annotation.*; 14 | 15 | import java.util.HashMap; 16 | import java.util.List; 17 | 18 | /** 19 | * @author 大漠穷秋 20 | */ 21 | @Slf4j 22 | @RestController 23 | @RequestMapping("/blog") 24 | public class CommentController { 25 | @Autowired 26 | private CommentRepository commentRepository; 27 | 28 | //TODO:每页显示的条数改为系统配置项 29 | private Integer pageSize=10; 30 | 31 | @RequestMapping(value = "/comment/{postId}/page/{page}", method = RequestMethod.GET) 32 | public ResponseEntity getCommentList(@PathVariable(value="postId") String postId,@PathVariable(value="page",required = false) Integer page) { 33 | if(page==null||page<=0){ 34 | page=1; 35 | } 36 | page=page-1; 37 | Page commentEntities=commentRepository.findByPostId(postId,new PageRequest(page,pageSize)); 38 | log.debug(commentEntities.toString()); 39 | return new ResponseEntity<>(commentEntities, HttpStatus.OK); 40 | } 41 | 42 | @RequestMapping(value="/comment/write-comment",method = RequestMethod.POST) 43 | public ResponseEntity writeComment(@RequestBody CommentEntity commentEntity){ 44 | commentEntity=commentRepository.save(commentEntity); 45 | return new ResponseEntity<>(commentEntity, HttpStatus.OK); 46 | } 47 | 48 | @RequestMapping(value = "/manage/comment-table", method = RequestMethod.POST) 49 | public ResponseEntity getPostListByUserId(@RequestBody HashMap params) { 50 | Integer page=Integer.valueOf(params.get("page")); 51 | Integer userId=Integer.valueOf(params.get("userId")); 52 | if(page==null||page<=0){ 53 | page=1; 54 | } 55 | page=page-1; 56 | 57 | List commentEntities=commentRepository.findCommentByUserIdAndPaging(userId,page*pageSize,pageSize); 58 | Long totalElements=commentRepository.countByUserId(userId); 59 | Integer totalPages=(int)(totalElements/pageSize+1); 60 | 61 | HashMap resultMap=new HashMap(); 62 | resultMap.put("totalElements",totalElements); 63 | resultMap.put("totalPages",totalPages); 64 | resultMap.put("size",pageSize); 65 | resultMap.put("content",commentEntities); 66 | 67 | return new ResponseEntity<>(resultMap, HttpStatus.OK); 68 | } 69 | 70 | @PreAuthorize("hasAnyRole('del_comment')") 71 | @RequestMapping(value = "/manage/del-comment/{commentId}",method = RequestMethod.DELETE) 72 | public ResponseEntity delPostById(@PathVariable(value="commentId",required = true) Integer commentId){ 73 | commentRepository.delete(commentId); 74 | return new ResponseEntity<>(new AjaxResponseEntity(true,"删除成功"),HttpStatus.OK); 75 | } 76 | } -------------------------------------------------------------------------------- /nicefish-user-center/src/main/java/com/fish/user/config/SecurityConfig.java: -------------------------------------------------------------------------------- 1 | package com.fish.user.config; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.beans.factory.annotation.Value; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.context.annotation.Primary; 8 | import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; 9 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; 10 | import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; 11 | import org.springframework.security.config.http.SessionCreationPolicy; 12 | import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter; 13 | import org.springframework.security.oauth2.config.annotation.web.configurers.ResourceServerSecurityConfigurer; 14 | import org.springframework.security.oauth2.provider.token.DefaultTokenServices; 15 | import org.springframework.security.oauth2.provider.token.TokenStore; 16 | import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter; 17 | import org.springframework.security.oauth2.provider.token.store.JwtTokenStore; 18 | 19 | /** 20 | * 注意这里继承的是 ResourceServerConfigurerAdapter,而不是普通的 WebSecurityConfigurerAdapter。 21 | * 这里会利用自定义的 FishJwtTokenConverter 来解析 JWT Token 。 22 | * @see FishJwtTokenConverter 23 | * @see ResourceServerConfigurerAdapter 24 | * @see org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter 25 | * @author 大漠穷秋 26 | */ 27 | @Configuration 28 | @EnableWebSecurity 29 | @EnableGlobalMethodSecurity(prePostEnabled = true) 30 | public class SecurityConfig extends ResourceServerConfigurerAdapter { 31 | @Value("${spring.security.oauth2.resource.jwt.key-value}") 32 | private String publicKey; 33 | 34 | @Autowired 35 | private FishJwtTokenConverter fishJwtTokenConverter; 36 | 37 | @Override 38 | public void configure(HttpSecurity http) throws Exception { 39 | http.authorizeRequests() 40 | .anyRequest().permitAll() 41 | .and() 42 | .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.NEVER) 43 | .and() 44 | .csrf().disable(); 45 | } 46 | 47 | @Override 48 | public void configure(final ResourceServerSecurityConfigurer config) { 49 | config.tokenServices(tokenServices()); 50 | } 51 | @Bean 52 | public TokenStore tokenStore() { 53 | return new JwtTokenStore(accessTokenConverter()); 54 | } 55 | 56 | @Bean 57 | public JwtAccessTokenConverter accessTokenConverter() { 58 | final JwtAccessTokenConverter converter = new JwtAccessTokenConverter(); 59 | converter.setAccessTokenConverter(fishJwtTokenConverter); 60 | converter.setVerifierKey(publicKey); 61 | return converter; 62 | } 63 | 64 | @Bean 65 | @Primary 66 | public DefaultTokenServices tokenServices() { 67 | final DefaultTokenServices defaultTokenServices = new DefaultTokenServices(); 68 | defaultTokenServices.setTokenStore(tokenStore()); 69 | return defaultTokenServices; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /nicefish-user-center/src/main/java/com/fish/user/config/FishJwtTokenConverter.java: -------------------------------------------------------------------------------- 1 | package com.fish.user.config; 2 | 3 | import org.springframework.security.core.GrantedAuthority; 4 | import org.springframework.security.oauth2.provider.OAuth2Authentication; 5 | import org.springframework.security.oauth2.provider.token.DefaultAccessTokenConverter; 6 | import org.springframework.stereotype.Component; 7 | 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | import java.util.Map; 11 | 12 | /** 13 | * 由于我们在OAuth服务器上给用户资料增加了自定义的字段,所以这里自定义一个JWT Token转换器。 14 | * Resource服务器会利用这个转换器解析JWT的Token,从而获得对应的用户资料和授权信息。 15 | * @author 大漠穷秋 16 | */ 17 | @Component 18 | public class FishJwtTokenConverter extends DefaultAccessTokenConverter{ 19 | @Override 20 | public OAuth2Authentication extractAuthentication(Map map) { 21 | OAuth2Authentication auth = super.extractAuthentication(map); 22 | AccessTokenMapper details = new AccessTokenMapper(); 23 | if (map.get("id") != null) 24 | details.setId((Integer) map.get("id")); 25 | if (map.get("first_name") != null) 26 | details.setFirst_name((String) map.get("first_name")); 27 | if (map.get("last_name") != null) 28 | details.setLast_name((String) map.get("last_name")); 29 | if (map.get("mobile") != null) 30 | details.setMobile((String) map.get("mobile")); 31 | if (auth.getAuthorities() != null && !auth.getAuthorities().isEmpty()) { 32 | List authorities = new ArrayList<>(); 33 | for (GrantedAuthority gn : auth.getAuthorities()) { 34 | authorities.add(gn.getAuthority()); 35 | } 36 | details.setAuthorities(authorities); 37 | } 38 | auth.setDetails(details); 39 | return auth; 40 | } 41 | 42 | class AccessTokenMapper { 43 | private Integer id; 44 | private String first_name; 45 | private String last_name; 46 | private String mobile; 47 | private String country; 48 | private List authorities = new ArrayList(); 49 | 50 | public Integer getId() { 51 | return id; 52 | } 53 | 54 | public void setId(Integer id) { 55 | this.id = id; 56 | } 57 | 58 | public List getAuthorities() { 59 | return authorities; 60 | } 61 | 62 | public void setAuthorities(List authorities) { 63 | this.authorities = authorities; 64 | } 65 | 66 | public String getFirst_name() { 67 | return first_name; 68 | } 69 | 70 | public void setFirst_name(String first_name) { 71 | this.first_name = first_name; 72 | } 73 | 74 | public String getLast_name() { 75 | return last_name; 76 | } 77 | 78 | public void setLast_name(String last_name) { 79 | this.last_name = last_name; 80 | } 81 | 82 | public String getMobile() { 83 | return mobile; 84 | } 85 | 86 | public void setMobile(String mobile) { 87 | this.mobile = mobile; 88 | } 89 | 90 | public String getCountry() { 91 | return country; 92 | } 93 | 94 | public void setCountry(String country) { 95 | this.country = country; 96 | } 97 | } 98 | } -------------------------------------------------------------------------------- /nicefish-blog/src/main/java/com/fish/blog/entity/CommentEntity.java: -------------------------------------------------------------------------------- 1 | package com.fish.blog.entity; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | 5 | import javax.persistence.*; 6 | import java.io.Serializable; 7 | import java.util.Date; 8 | 9 | /** 10 | * @author 大漠穷秋 11 | * @version 创建时间:2018-12-31 17:00 12 | */ 13 | @Entity 14 | @Table(name="blog_comment") 15 | public class CommentEntity implements Serializable { 16 | @Id 17 | @Column(name="CommentId") 18 | @GeneratedValue(strategy = GenerationType.IDENTITY) 19 | private Integer id; 20 | @Column(name="PostId") 21 | private Integer postId; 22 | @Lob 23 | @Column(name = "Content",columnDefinition="text") 24 | private String content; 25 | @Temporal(TemporalType.TIMESTAMP) 26 | @Column(name = "CommentTime") 27 | @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss") 28 | private Date time; 29 | @Column(name="CommentIp") 30 | private String ip; 31 | @Column(name="p_id") 32 | private String pId; 33 | @Column(name = "UserId") 34 | private Integer userId; 35 | @Column(name = "UserName") 36 | private String userName; 37 | @Column(name = "NickName") 38 | private String nickName; 39 | @Column(name = "Email") 40 | private String email; 41 | @Column(name = "Status") 42 | private Integer status; 43 | 44 | public Integer getId() { 45 | return id; 46 | } 47 | 48 | public void setId(Integer id) { 49 | this.id = id; 50 | } 51 | 52 | public String getContent() { 53 | return content; 54 | } 55 | 56 | public void setContent(String content) { 57 | this.content = content; 58 | } 59 | 60 | public Date getTime() { 61 | return time; 62 | } 63 | 64 | public void setTime(Date time) { 65 | this.time = time; 66 | } 67 | 68 | public String getIp() { 69 | return ip; 70 | } 71 | 72 | public void setIp(String ip) { 73 | this.ip = ip; 74 | } 75 | 76 | public String getpId() { 77 | return pId; 78 | } 79 | 80 | public void setpId(String pId) { 81 | this.pId = pId; 82 | } 83 | 84 | public Integer getUserId() { 85 | return userId; 86 | } 87 | 88 | public void setUserId(Integer userId) { 89 | this.userId = userId; 90 | } 91 | 92 | public String getUserName() { 93 | return userName; 94 | } 95 | 96 | public void setUserName(String userName) { 97 | this.userName = userName; 98 | } 99 | 100 | public String getNickName() { 101 | return nickName; 102 | } 103 | 104 | public void setNickName(String nickName) { 105 | this.nickName = nickName; 106 | } 107 | 108 | public String getEmail() { 109 | return email; 110 | } 111 | 112 | public void setEmail(String email) { 113 | this.email = email; 114 | } 115 | 116 | public Integer getStatus() { 117 | return status; 118 | } 119 | 120 | public void setStatus(Integer status) { 121 | this.status = status; 122 | } 123 | 124 | public Integer getPostId() { 125 | return postId; 126 | } 127 | 128 | public void setPostId(Integer postId) { 129 | this.postId = postId; 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /nicefish-oauth2-jwt/src/main/java/com/fish/oauth/config/OAuth2Config.java: -------------------------------------------------------------------------------- 1 | package com.fish.oauth.config; 2 | 3 | import com.fish.oauth.util.JwtAccessTokenConverterEnhancer; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.beans.factory.annotation.Qualifier; 6 | import org.springframework.beans.factory.annotation.Value; 7 | import org.springframework.context.annotation.Configuration; 8 | import org.springframework.security.authentication.AuthenticationManager; 9 | import org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer; 10 | import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter; 11 | import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerEndpointsConfigurer; 12 | import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerSecurityConfigurer; 13 | import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter; 14 | import org.springframework.security.oauth2.provider.token.store.JwtTokenStore; 15 | 16 | /** 17 | * OAuth2 服务器配置 18 | * @author 大漠穷秋 19 | */ 20 | @Configuration 21 | public class OAuth2Config extends AuthorizationServerConfigurerAdapter { 22 | 23 | @Value("${config.oauth2.clientId}") 24 | private String clientId; 25 | 26 | @Value("${config.oauth2.clientSecret}") 27 | private String clientSecret; 28 | 29 | @Value("${config.oauth2.accessTokenValiditySeconds}") 30 | private int accessTokenValiditySeconds; 31 | 32 | @Value("${config.oauth2.refreshTokenValiditySeconds}") 33 | private int refreshTokenValiditySeconds; 34 | 35 | @Value("${config.oauth2.privateKey}") 36 | private String privateKey; 37 | 38 | @Value("${config.oauth2.publicKey}") 39 | private String publicKey; 40 | 41 | @Autowired 42 | @Qualifier("authenticationManagerBean") 43 | private AuthenticationManager authenticationManager; 44 | 45 | @Override 46 | public void configure(AuthorizationServerSecurityConfigurer server) throws Exception { 47 | // @formatter:off 48 | server.tokenKeyAccess("permitAll()") 49 | .checkTokenAccess("permitAll()") 50 | .allowFormAuthenticationForClients(); 51 | // @formatter:on 52 | } 53 | 54 | @Override 55 | public void configure(ClientDetailsServiceConfigurer clients) throws Exception { 56 | clients.inMemory() 57 | .withClient(clientId) 58 | .secret(clientSecret) 59 | .scopes("read", "write", "trust") 60 | .authorizedGrantTypes("authorization_code", "implicit", "password", "client_credentials", "refresh_token") 61 | .accessTokenValiditySeconds(accessTokenValiditySeconds) 62 | .refreshTokenValiditySeconds(refreshTokenValiditySeconds); 63 | } 64 | 65 | @Override 66 | public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception { 67 | JwtAccessTokenConverter converter = new JwtAccessTokenConverterEnhancer(); 68 | converter.setSigningKey(privateKey); 69 | converter.setVerifierKey(publicKey); 70 | 71 | endpoints.authenticationManager(authenticationManager) 72 | .tokenStore(new JwtTokenStore(converter)) 73 | .accessTokenConverter(converter); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /nicefish-user-center/src/main/java/com/fish/user/entity/UserEntity.java: -------------------------------------------------------------------------------- 1 | package com.fish.user.entity; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import org.springframework.security.core.GrantedAuthority; 5 | 6 | import javax.persistence.*; 7 | import java.util.ArrayList; 8 | import java.util.Collection; 9 | import java.util.Set; 10 | 11 | /** 12 | * 与数据库表字段一一对应。 13 | * @author 大漠穷秋 14 | */ 15 | @Entity 16 | @Table(name = "auth_user") 17 | public class UserEntity { 18 | @Id 19 | @GeneratedValue(strategy = GenerationType.IDENTITY) 20 | @Column(name = "id") 21 | private Integer id; 22 | @Column(name = "email") 23 | private String email; 24 | @Column(name = "mobile") 25 | private String mobile; 26 | @Column(name = "password") 27 | private String password; 28 | @Column(name = "FirstName") 29 | private String firstName; 30 | @Column(name = "LastName") 31 | private String lastName; 32 | @Column(name = "NickName") 33 | private String nickName; 34 | @Column(name = "country") 35 | private String country; 36 | @ManyToMany(cascade = CascadeType.PERSIST,fetch = FetchType.LAZY) 37 | @JoinTable(name = "auth_user_role", 38 | joinColumns = {@JoinColumn(name = "user_id", referencedColumnName = "id")}, 39 | inverseJoinColumns = {@JoinColumn(name = "role_id", referencedColumnName = "id")}) 40 | @JsonIgnore 41 | private Set roles; 42 | 43 | @Transient 44 | private Collection grantedAuthoritiesList = new ArrayList(); 45 | 46 | public Integer getId() { 47 | return id; 48 | } 49 | 50 | public void setId(Integer id) { 51 | this.id = id; 52 | } 53 | 54 | public String getEmail() { 55 | return email; 56 | } 57 | 58 | public void setEmail(String email) { 59 | this.email = email; 60 | } 61 | 62 | public String getMobile() { 63 | return mobile; 64 | } 65 | 66 | public void setMobile(String mobile) { 67 | this.mobile = mobile; 68 | } 69 | 70 | public String getPassword() { 71 | return password; 72 | } 73 | 74 | public void setPassword(String password) { 75 | this.password = password; 76 | } 77 | 78 | public String getFirstName() { 79 | return firstName; 80 | } 81 | 82 | public void setFirstName(String firstName) { 83 | this.firstName = firstName; 84 | } 85 | 86 | public String getLastName() { 87 | return lastName; 88 | } 89 | 90 | public void setLastName(String lastName) { 91 | this.lastName = lastName; 92 | } 93 | 94 | public String getCountry() { 95 | return country; 96 | } 97 | 98 | public void setCountry(String country) { 99 | this.country = country; 100 | } 101 | 102 | public Collection getGrantedAuthoritiesList() { 103 | return grantedAuthoritiesList; 104 | } 105 | 106 | public void setGrantedAuthoritiesList(Collection grantedAuthoritiesList) { 107 | this.grantedAuthoritiesList = grantedAuthoritiesList; 108 | } 109 | 110 | public Set getRoles() { 111 | return roles; 112 | } 113 | 114 | public void setRoles(Set roles) { 115 | this.roles = roles; 116 | } 117 | 118 | public String getNickName() { 119 | return nickName; 120 | } 121 | 122 | public void setNickName(String nickName) { 123 | this.nickName = nickName; 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | com.fish 6 | nicefish-spring-cloud 7 | 0.0.1-SNAPSHOT 8 | nicefish-spring-cloud 9 | NiceFish的服务端代码。 10 | pom 11 | 12 | 13 | nicefish-oauth2-jwt 14 | nicefish-user-center 15 | nicefish-blog 16 | nicefish-swagger2-api 17 | nicefish-zuul-server 18 | 19 | 20 | 21 | org.springframework.boot 22 | spring-boot-starter-parent 23 | 24 | 1.5.19.RELEASE 25 | 26 | 27 | 28 | 29 | UTF-8 30 | UTF-8 31 | 1.8 32 | Edgware.RELEASE 33 | 34 | 35 | 36 | 37 | org.springframework.boot 38 | spring-boot-starter-data-redis 39 | 40 | 41 | 42 | mysql 43 | mysql-connector-java 44 | runtime 45 | 46 | 47 | org.springframework.boot 48 | spring-boot-starter-data-jpa 49 | 50 | 51 | com.alibaba 52 | druid-spring-boot-starter 53 | 1.1.10 54 | 55 | 56 | 57 | com.h2database 58 | h2 59 | 1.3.156 60 | 61 | 62 | 63 | org.projectlombok 64 | lombok 65 | 1.18.4 66 | provided 67 | 68 | 69 | 70 | org.springframework.boot 71 | spring-boot-devtools 72 | runtime 73 | 74 | 75 | org.springframework.boot 76 | spring-boot-starter-test 77 | test 78 | 79 | 80 | org.springframework.boot 81 | spring-boot-starter-web 82 | 83 | 84 | 85 | org.springframework.cloud 86 | spring-cloud-starter-consul-discovery 87 | 88 | 89 | 90 | org.springframework.boot 91 | spring-boot-starter-actuator 92 | compile 93 | 94 | 95 | 96 | org.springframework.cloud 97 | spring-cloud-starter 98 | 99 | 100 | 101 | org.springframework.cloud 102 | spring-cloud-starter-oauth2 103 | 104 | 105 | 106 | com.google.code.gson 107 | gson 108 | 109 | 110 | 111 | 112 | 113 | 114 | org.springframework.cloud 115 | spring-cloud-dependencies 116 | ${spring-cloud.version} 117 | pom 118 | import 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | org.springframework.boot 127 | spring-boot-maven-plugin 128 | 129 | 130 | 131 | 132 | -------------------------------------------------------------------------------- /nicefish-user-center/src/main/java/com/fish/user/controller/UserController.java: -------------------------------------------------------------------------------- 1 | package com.fish.user.controller; 2 | 3 | import com.fish.user.entity.RoleRepository; 4 | import com.fish.user.entity.UserEntity; 5 | import com.fish.user.entity.UserRepository; 6 | import com.fish.user.util.AjaxResponseEntity; 7 | import lombok.extern.slf4j.Slf4j; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.http.HttpStatus; 10 | import org.springframework.http.ResponseEntity; 11 | import org.springframework.security.access.prepost.PreAuthorize; 12 | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; 13 | import org.springframework.web.bind.annotation.*; 14 | 15 | import java.util.ArrayList; 16 | import java.util.HashMap; 17 | import java.util.List; 18 | /** 19 | * @author 大漠穷秋 20 | */ 21 | @Slf4j 22 | @RestController 23 | @RequestMapping("/users") 24 | public class UserController { 25 | @Autowired 26 | UserRepository userRepository; 27 | 28 | @Autowired 29 | RoleRepository roleRepository; 30 | 31 | //TODO:每页显示的条数改为系统配置项 32 | private Integer pageSize=10; 33 | 34 | @RequestMapping(value = "/{id}",method = RequestMethod.GET) 35 | public ResponseEntity getUserDetail(@PathVariable("id") Integer id) { 36 | return new ResponseEntity<>(userRepository.findOne(id), HttpStatus.OK); 37 | } 38 | 39 | @RequestMapping(value = "/create", method = RequestMethod.POST) 40 | public ResponseEntity createUser(@RequestBody UserEntity userEntity) { 41 | //TODO:加参数校验 42 | if(userRepository.findByEmail(userEntity.getEmail())==null){ 43 | return new ResponseEntity<>(new AjaxResponseEntity(false,"邮箱已经被使用"), HttpStatus.OK); 44 | } 45 | //TODO:不允许创建大于或等于自己权限的用户 46 | //TODO:用户创建完成之后自动赋予查看和发帖权限 47 | BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); 48 | userEntity.setPassword(passwordEncoder.encode(userEntity.getPassword())); 49 | UserEntity result=userRepository.save(userEntity); 50 | result.setPassword(""); 51 | log.debug(result.getId().toString()); 52 | return new ResponseEntity<>(new AjaxResponseEntity(true,"创建成功",result), HttpStatus.OK); 53 | } 54 | 55 | @RequestMapping(value = "/edit/{id}", method = RequestMethod.POST) 56 | public ResponseEntity updateUser(@PathVariable("id") Integer id, @RequestBody UserEntity userEntity) { 57 | //TODO:数据和业务逻辑校验,不准修改邮箱,邮箱格式必须合法 58 | //TODO:数据保护,不允许编辑比自己权限高的用户 59 | userRepository.save(userEntity); 60 | return new ResponseEntity<>("User updated successfully", HttpStatus.OK); 61 | } 62 | 63 | @RequestMapping(value = "/delete/{id}", method = RequestMethod.GET) 64 | public ResponseEntity deleteUser(@PathVariable("id") Integer id) { 65 | //TODO:数据保护,不允许删除比自己权限高的用户 66 | userRepository.delete(id); 67 | return new ResponseEntity<>(new AjaxResponseEntity(true,"删除成功"), HttpStatus.OK); 68 | } 69 | 70 | @RequestMapping(value = "/roles/{id}/users", method = RequestMethod.GET) 71 | public ResponseEntity viewUsersByRole(@PathVariable("id") Integer roleId) { 72 | return new ResponseEntity<>(roleRepository.findOne(roleId), HttpStatus.OK); 73 | } 74 | 75 | @RequestMapping(value = "/roles/{id}/users", method = RequestMethod.PUT) 76 | public ResponseEntity assignUsers2Role(@PathVariable("id") Integer roleId, @RequestBody ArrayList usersList) { 77 | //TODO:这里需要重新实现 78 | return new ResponseEntity<>("Users are assigned to role successfully", HttpStatus.OK); 79 | } 80 | 81 | @PreAuthorize("hasAnyRole('view_users')") 82 | @RequestMapping(value = "/user-table", method = RequestMethod.POST) 83 | public ResponseEntity getUserListByPaging(@RequestBody HashMap params) { 84 | Integer page=Integer.valueOf(params.get("page")); 85 | if(page==null||page<=0){ 86 | page=1; 87 | } 88 | page=page-1; 89 | 90 | List postEntities=userRepository.findByPageing(page*pageSize,pageSize); 91 | Long totalElements=userRepository.countAllRows(); 92 | Integer totalPages=(int)(totalElements/pageSize+1); 93 | 94 | HashMap resultMap=new HashMap(); 95 | resultMap.put("totalElements",totalElements); 96 | resultMap.put("totalPages",totalPages); 97 | resultMap.put("size",pageSize); 98 | resultMap.put("content",postEntities); 99 | 100 | return new ResponseEntity<>(resultMap, HttpStatus.OK); 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 |

4 | 5 |

NiceFish

6 | 7 |
8 | NiceFish(美人鱼) 是一个系列项目,目标是全面示范前后端分离的开发模式,前端浏览器、移动端、Electron 环境中的各种开发模式,后端采用基于 SpringCloud 的微服务实现。 9 |
10 | 11 | ## NiceFish-Spring-Cloud 12 | 13 | 本项目是NiceFish的服务端代码,已经实现的技术特性和业务功能有: 14 | 15 | - 用Consul进行服务注册和发现 16 | - 用Zuul对外暴露统一的REST服务入口 17 | - 用HystrixDashboard监控微服务的调用,用Turbine整合数据图表 18 | - 用SpringSecurity+OAuth2+JWT实现SSO 19 | - 用Druid监控MySQL 20 | - 集成lombok,用注解的方式调用日志服务 21 | - 文章管理(列表分页查询、新增文章) 22 | - 评论管理(列表分页查询) 23 | - 用户管理(注册、登录、SSO) 24 | 25 | 用到的主要模块: 26 | - spring-cloud-starter-consul-discovery 27 | - spring-cloud-starter-zuul 28 | - spring-cloud-starter-netflix-hystrix-dashboard 29 | - spring-cloud-oauth2 30 | - spring-boot-starter-data-jpa 31 | - mysql-connector-java 32 | - springfox-swagger2 33 | - druid-spring-boot-starter 34 | - lombok 35 | - gson 36 | 37 | ## Maven Module 模块功能和依赖关系 38 | 39 |

40 | 41 |

42 | 43 | 44 | Maven 模块之间的依赖关系 45 | 46 |

47 | 48 |

49 | 50 | - nicefish-spring-cloud:这是root项目,通用的依赖都定义在这个项目的pom.xml中,子Module会自动继承这里的依赖关系。 51 | - nicefish-zuul-server:这是所有外部调用的总入口,Zuul会自动到Consul上获取所有RestAPI,依赖nicefish-user-center模块中的配置和UserEntity等。Zuul内部已经使用了Ribbon和Hystrix,因此不需要单独在pom.xml中引入这两个模块,直接配置即可,默认访问路径是:http://localhost:9500/hystrix 52 | - nicefish-user-center:这是用户中心模块,它是独立的不依赖其它子模块。 53 | - nicefish-blog:这里实现blog相关的功能,如文章和评论等,依赖nicefish-user-center模块中的配置和UserEntity等。 54 | - nicefish-oauth2-jwt:这里实现OAuth和JWT相关的功能,依赖nicefish-user-center模块中的UserEntity和Repository等。 55 | - nicefish-swagger2-api:这里是所有API文档的总入口,依赖nicefish-user-center、nicefish-blog、nicefish-oauth2-jwt模块,解析并生成API文档,访问地址是 http://localhost:9004/swagger-ui.html#/ 56 | - Druid 监控访问路径:http://127.0.0.1:9500/druid/index.html ,默认用户名和密码admin/123456 57 | 58 | ## 使用方法 59 | 60 | - 安装配置好JDK,需要Java 1.8以上版本。 61 | - 安装配置好IDEA,并安装lombok插件,@Slf4j日志工具需要用到lombok,参考 https://blog.csdn.net/qq_26525215/article/details/79182628 62 | - 安装配置好maven,或者使用IDEA内置的maven。 63 | - 安装配置好Consul(默认HTTP端口是8500),以dev的方式启动agent(命令行执行consul agent -dev),其它配置请仔细参照官方文档:https://www.consul.io/ 。 64 | - 克隆项目到你的本地:git clone https://gitee.com/mumu-osc/nicefish-spring-cloud.git 。 65 | - 安装配置好MySQL或者MariaDB,MySQL需要5.x以上,MariaDB需要10.x以上。 66 | - 在你本地的MySQL里面建一个库,名为nicefish,然后执行 /doc/nicefish.sql 建表。 67 | - 用IDEA导入根项目nicefish-spring-cloud的pom.xml 。 68 | - 启动所有子模块(有顺序):NiceFishOAuthApplication.java、NiceFishUserCenterApplication.java、NiceFishBlogApplication.java、NiceFishZuulServerApplication.java 。 69 | - 使用Postman或者NiceFish的前端项目来测试Restful接口(Zuul网关默认起在9500端口、OAuth服务默认起在9100端口,用户中心模块默认起在9200端口,blog相关的模块默认起在9300端口,Swagger2文档服务默认起在9400端口,内置了一个测试账号damoqiongqiu@126.com,密码12345678,密码对应的MD5是25d55ad283aa400af464c76d713c07ad) 。 70 | - 前端代码:https://gitee.com/mumu-osc/NiceFish ,NiceFish与本项目对接的代码位于for-spring-cloud分支上,里面有完整的使用说明,请仔细阅读Readme文档。 71 | 72 | ## 特别注意 73 | 74 | - **此项目在 SpringBoot 1.5.9.RELEASE 和 SpringCloud Edgware.RELEASE 测试通过,其它所有版本都未经测试。(SpringBoot和SpringCloud之间存在版本对应关系,版本升级可能需要修改非常多的琐碎细节。如果您需要升级版本,请仔细查阅Spring官方的文档,以免浪费大量时间。)** 75 | - **项目本身的代码是独立的,没有与任何前端技术绑定,因此您可以使用任意前端技术接入。** 76 | 77 | ## 效果截图 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | ## 系列项目 96 | 97 | * NiceFish:美人鱼,这是一个微型 Blog 系统,前端基于 Angular 7.0 + PrimeNG 7.0.3。http://git.oschina.net/mumu-osc/NiceFish/ 98 | 99 | * nicefish-ionic:这是一个移动端的 demo,基于 ionic,此项目已支持 PWA。http://git.oschina.net/mumu-osc/nicefish-ionic 100 | 101 | * NiceBlogElectron:https://github.com/damoqiongqiu/NiceBlogElectron ,这是一个基于 Electron 的桌面端项目,把 NiceFish 用 Electron 打包成了一个桌面端运行的程序。这是由 ZTE 中兴通讯的前端道友提供的,我 fork 了一个,有几个 node 模块的版本号老要改,如果您正在研究如何利用 Electron 开发桌面端应用,请参考这个项目。 102 | 103 | * nicefish-spring-cloud: https://gitee.com/mumu-osc/nicefish-spring-cloud , 这是NiceFish的服务端代码,基于SpringCloud。已经完成了一些基本的功能,如 SpringSecurity+OAuth2+JWT 实现SSO,文章、用户、评论等的分页查询等。如果你需要与这个后端代码进行对接,请检出本项目的 for-spring-cloud 分支。 104 | 105 | ## 关联 QQ 群 106 | 107 | 108 | 109 | ## License 110 | 111 | MIT -------------------------------------------------------------------------------- /nicefish-blog/src/main/java/com/fish/blog/entity/PostEntity.java: -------------------------------------------------------------------------------- 1 | package com.fish.blog.entity; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | 5 | import javax.persistence.*; 6 | import java.io.Serializable; 7 | import java.util.Date; 8 | 9 | /** 10 | * @author 大漠穷秋 11 | * @version 创建时间:2018-12-31 17:00 12 | */ 13 | @Entity 14 | @Table(name="blog_post") 15 | public class PostEntity implements Serializable { 16 | @Id 17 | @Column(name="PostId") 18 | @GeneratedValue(strategy = GenerationType.IDENTITY) 19 | private Integer id; 20 | @Column(name = "BgImg") 21 | private String bgImg; 22 | @Column(name="PostTitle") 23 | private String title; 24 | @Temporal(TemporalType.TIMESTAMP) 25 | @Column(name="PostTime") 26 | @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss") 27 | private Date time; 28 | @Lob 29 | @Column(name="PostContent",columnDefinition="text") 30 | private String content; 31 | @Column(name="PostSummary") 32 | private String summary; 33 | @Column(name="OriginalUrl") 34 | private String originalURL=""; 35 | @Column(name="PostType") 36 | private Integer postType=0; 37 | @Temporal(TemporalType.TIMESTAMP) 38 | @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss") 39 | @Column(name="LastModifyTime") 40 | private Date lastModifyTime=new Date(); 41 | @Column(name = "ReadTimes") 42 | private Integer readTimes=1; 43 | @Column(name="LikedTimes") 44 | private Integer likedTimes=0; 45 | @Column(name="CommentTimes") 46 | private Integer commentTimes=0; 47 | @Column(name="UserId") 48 | private Integer userId; 49 | @Basic(optional=true) 50 | @Column(name="Email") 51 | private String email; 52 | @Column(name="NickName") 53 | private String nickName; 54 | @Column(name="EnableComment") 55 | private Integer enableComment=1; 56 | @Column(name="Status") 57 | private Integer status=4; 58 | 59 | public Integer getId() { 60 | return id; 61 | } 62 | 63 | public void setId(Integer id) { 64 | this.id = id; 65 | } 66 | 67 | public String getTitle() { 68 | return title; 69 | } 70 | 71 | public void setTitle(String title) { 72 | this.title = title; 73 | } 74 | 75 | public String getContent() { 76 | return content; 77 | } 78 | 79 | public void setContent(String content) { 80 | this.content = content; 81 | } 82 | 83 | public Date getTime() { 84 | return time; 85 | } 86 | 87 | public void setTime(Date time) { 88 | this.time = time; 89 | } 90 | 91 | public String getOriginalURL() { 92 | return originalURL; 93 | } 94 | 95 | public void setOriginalURL(String originalURL) { 96 | this.originalURL = originalURL; 97 | } 98 | 99 | public Integer getPostType() { 100 | return postType; 101 | } 102 | 103 | public void setPostType(Integer postType) { 104 | this.postType = postType; 105 | } 106 | 107 | public Date getLastModifyTime() { 108 | return lastModifyTime; 109 | } 110 | 111 | public void setLastModifyTime(Date lastModifyTime) { 112 | this.lastModifyTime = lastModifyTime; 113 | } 114 | 115 | public Integer getReadTimes() { 116 | return readTimes; 117 | } 118 | 119 | public void setReadTimes(Integer readTimes) { 120 | this.readTimes = readTimes; 121 | } 122 | 123 | public Integer getLikedTimes() { 124 | return likedTimes; 125 | } 126 | 127 | public void setLikedTimes(Integer likedTimes) { 128 | this.likedTimes = likedTimes; 129 | } 130 | 131 | public Integer getCommentTimes() { 132 | return commentTimes; 133 | } 134 | 135 | public void setCommentTimes(Integer commentTimes) { 136 | this.commentTimes = commentTimes; 137 | } 138 | 139 | public Integer getUserId() { 140 | return userId; 141 | } 142 | 143 | public void setUserId(Integer userId) { 144 | this.userId = userId; 145 | } 146 | 147 | public String getEmail() { 148 | return email; 149 | } 150 | 151 | public void setEmail(String email) { 152 | this.email = email; 153 | } 154 | 155 | public String getNickName() { 156 | return nickName; 157 | } 158 | 159 | public void setNickName(String nickName) { 160 | this.nickName = nickName; 161 | } 162 | 163 | public Integer getEnableComment() { 164 | return enableComment; 165 | } 166 | 167 | public void setEnableComment(Integer enableComment) { 168 | this.enableComment = enableComment; 169 | } 170 | 171 | public Integer getStatus() { 172 | return status; 173 | } 174 | 175 | public void setStatus(Integer status) { 176 | this.status = status; 177 | } 178 | 179 | public String getSummary() { 180 | return summary; 181 | } 182 | 183 | public void setSummary(String summary) { 184 | this.summary = summary; 185 | } 186 | 187 | public String getBgImg() { 188 | return bgImg; 189 | } 190 | 191 | public void setBgImg(String bgImg) { 192 | this.bgImg = bgImg; 193 | } 194 | } 195 | -------------------------------------------------------------------------------- /nicefish-blog/src/main/java/com/fish/blog/controller/PostController.java: -------------------------------------------------------------------------------- 1 | package com.fish.blog.controller; 2 | 3 | import com.fish.blog.entity.PostEntity; 4 | import com.fish.blog.service.IPostService; 5 | import com.fish.user.util.AjaxResponseEntity; 6 | import lombok.extern.slf4j.Slf4j; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.cloud.client.ServiceInstance; 9 | import org.springframework.cloud.client.loadbalancer.LoadBalancerClient; 10 | import org.springframework.data.domain.Page; 11 | import org.springframework.data.domain.PageRequest; 12 | import org.springframework.http.HttpStatus; 13 | import org.springframework.http.ResponseEntity; 14 | import org.springframework.security.access.prepost.PreAuthorize; 15 | import org.springframework.web.bind.annotation.*; 16 | import org.springframework.web.client.RestTemplate; 17 | 18 | import java.util.HashMap; 19 | import java.util.List; 20 | 21 | /** 22 | * @author 大漠穷秋 23 | */ 24 | @Slf4j 25 | @RestController 26 | @RequestMapping("/blog") 27 | public class PostController { 28 | @Autowired 29 | private LoadBalancerClient loadBalancer; 30 | 31 | @Autowired 32 | private IPostService postService; 33 | 34 | //TODO:每页显示的条数改为系统配置项 35 | private Integer pageSize=10; 36 | 37 | @RequestMapping(value = "/post-list/{page}", method = RequestMethod.GET) 38 | public ResponseEntity getPostList(@PathVariable(value="page",required = false) Integer page) { 39 | if(page==null||page<=0){ 40 | page=1; 41 | } 42 | page=page-1; 43 | Page postEntities=postService.getPostsPaging(new PageRequest(page,pageSize)); 44 | return new ResponseEntity<>(postEntities, HttpStatus.OK); 45 | } 46 | 47 | @RequestMapping(value = "/post-detail/{id}",method = RequestMethod.GET) 48 | public ResponseEntity getPostDetail(@PathVariable(value = "id",required = true) Integer id){ 49 | return new ResponseEntity<>(postService.getOne(id), HttpStatus.OK); 50 | } 51 | 52 | @PreAuthorize("hasAnyRole('add_post')") 53 | @RequestMapping(value = "/write-post",method = RequestMethod.POST) 54 | public ResponseEntity writePost(@RequestBody PostEntity postEntity){ 55 | //用户相关的服务都在nicefish-user-center项目中实现,这里调用nicefish-user-center提供的微服务,获取用户昵称等资料 56 | ServiceInstance serviceInstance = loadBalancer.choose("nicefish-user-center"); 57 | HashMap serviceResult = new RestTemplate().getForObject( 58 | serviceInstance.getUri().toString() + "/users/"+postEntity.getUserId(), 59 | HashMap.class); 60 | 61 | log.debug(serviceResult.toString()); 62 | //TODO:如果没有查到用户资料,报错返回 63 | 64 | postEntity.setUserId((int)serviceResult.get("id")); 65 | postEntity.setEmail((String)serviceResult.get("email")); 66 | postEntity.setNickName(serviceResult.get("nickName")==null?"":serviceResult.get("nickName").toString()); 67 | 68 | //TODO:返回的数据里面没有id,事务问题? 69 | postService.savePost(postEntity); 70 | return new ResponseEntity<>(postEntity, HttpStatus.OK); 71 | } 72 | 73 | @PreAuthorize("hasAnyRole('edit_post')") 74 | @RequestMapping(value = "/edit-post",method = RequestMethod.POST) 75 | public ResponseEntity editPost(@RequestBody PostEntity postEntity){ 76 | //用户相关的服务都在nicefish-user-center项目中实现,这里调用nicefish-user-center提供的微服务,获取用户昵称等资料 77 | ServiceInstance serviceInstance = loadBalancer.choose("nicefish-user-center"); 78 | HashMap serviceResult = new RestTemplate().getForObject( 79 | serviceInstance.getUri().toString() + "/users/"+postEntity.getUserId(), 80 | HashMap.class); 81 | 82 | log.debug(serviceResult.toString()); 83 | //TODO:如果没有查到用户资料,报错返回 84 | 85 | postEntity.setUserId((int)serviceResult.get("id")); 86 | postEntity.setEmail((String)serviceResult.get("email")); 87 | postEntity.setNickName(serviceResult.get("nickName")==null?"":serviceResult.get("nickName").toString()); 88 | //TODO:返回的数据里面没有id,事务问题? 89 | postService.savePost(postEntity); 90 | return new ResponseEntity<>(postEntity, HttpStatus.OK); 91 | } 92 | 93 | @RequestMapping(value = "/manage/post-table", method = RequestMethod.POST) 94 | public ResponseEntity getPostListByUserId(@RequestBody HashMap params) { 95 | Integer page=Integer.valueOf(params.get("page")); 96 | Integer userId=Integer.valueOf(params.get("userId")); 97 | if(page==null||page<=0){ 98 | page=1; 99 | } 100 | page=page-1; 101 | 102 | List postEntities=postService.findByUserIdAndPaging(userId,page*pageSize,pageSize); 103 | Long totalElements=postService.countByUserId(userId); 104 | Integer totalPages=(int)(totalElements/pageSize+1); 105 | 106 | HashMap resultMap=new HashMap(); 107 | resultMap.put("totalElements",totalElements); 108 | resultMap.put("totalPages",totalPages); 109 | resultMap.put("size",pageSize); 110 | resultMap.put("content",postEntities); 111 | 112 | return new ResponseEntity<>(resultMap, HttpStatus.OK); 113 | } 114 | 115 | @PreAuthorize("hasAnyRole('del_post')") 116 | @RequestMapping(value = "/manage/del-post/{postId}",method = RequestMethod.DELETE) 117 | public ResponseEntity delPostById(@PathVariable(value="postId",required = true) Integer postId){ 118 | postService.delPost(postId); 119 | return new ResponseEntity<>(new AjaxResponseEntity(true,"删除成功"),HttpStatus.OK); 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /nicefish-blog/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM http://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven2 Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" 124 | FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO ( 125 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 126 | ) 127 | 128 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 129 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 130 | if exist %WRAPPER_JAR% ( 131 | echo Found %WRAPPER_JAR% 132 | ) else ( 133 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 134 | echo Downloading from: %DOWNLOAD_URL% 135 | powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')" 136 | echo Finished downloading %WRAPPER_JAR% 137 | ) 138 | @REM End of extension 139 | 140 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 141 | if ERRORLEVEL 1 goto error 142 | goto end 143 | 144 | :error 145 | set ERROR_CODE=1 146 | 147 | :end 148 | @endlocal & set ERROR_CODE=%ERROR_CODE% 149 | 150 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 151 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 152 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 153 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 154 | :skipRcPost 155 | 156 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 157 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 158 | 159 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 160 | 161 | exit /B %ERROR_CODE% 162 | -------------------------------------------------------------------------------- /nicefish-oauth2-jwt/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM http://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven2 Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" 124 | FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO ( 125 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 126 | ) 127 | 128 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 129 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 130 | if exist %WRAPPER_JAR% ( 131 | echo Found %WRAPPER_JAR% 132 | ) else ( 133 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 134 | echo Downloading from: %DOWNLOAD_URL% 135 | powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')" 136 | echo Finished downloading %WRAPPER_JAR% 137 | ) 138 | @REM End of extension 139 | 140 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 141 | if ERRORLEVEL 1 goto error 142 | goto end 143 | 144 | :error 145 | set ERROR_CODE=1 146 | 147 | :end 148 | @endlocal & set ERROR_CODE=%ERROR_CODE% 149 | 150 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 151 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 152 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 153 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 154 | :skipRcPost 155 | 156 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 157 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 158 | 159 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 160 | 161 | exit /B %ERROR_CODE% 162 | -------------------------------------------------------------------------------- /nicefish-swagger2-api/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM http://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven2 Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" 124 | FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO ( 125 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 126 | ) 127 | 128 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 129 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 130 | if exist %WRAPPER_JAR% ( 131 | echo Found %WRAPPER_JAR% 132 | ) else ( 133 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 134 | echo Downloading from: %DOWNLOAD_URL% 135 | powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')" 136 | echo Finished downloading %WRAPPER_JAR% 137 | ) 138 | @REM End of extension 139 | 140 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 141 | if ERRORLEVEL 1 goto error 142 | goto end 143 | 144 | :error 145 | set ERROR_CODE=1 146 | 147 | :end 148 | @endlocal & set ERROR_CODE=%ERROR_CODE% 149 | 150 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 151 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 152 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 153 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 154 | :skipRcPost 155 | 156 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 157 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 158 | 159 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 160 | 161 | exit /B %ERROR_CODE% 162 | -------------------------------------------------------------------------------- /nicefish-user-center/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM http://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven2 Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" 124 | FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO ( 125 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 126 | ) 127 | 128 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 129 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 130 | if exist %WRAPPER_JAR% ( 131 | echo Found %WRAPPER_JAR% 132 | ) else ( 133 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 134 | echo Downloading from: %DOWNLOAD_URL% 135 | powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')" 136 | echo Finished downloading %WRAPPER_JAR% 137 | ) 138 | @REM End of extension 139 | 140 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 141 | if ERRORLEVEL 1 goto error 142 | goto end 143 | 144 | :error 145 | set ERROR_CODE=1 146 | 147 | :end 148 | @endlocal & set ERROR_CODE=%ERROR_CODE% 149 | 150 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 151 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 152 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 153 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 154 | :skipRcPost 155 | 156 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 157 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 158 | 159 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 160 | 161 | exit /B %ERROR_CODE% 162 | -------------------------------------------------------------------------------- /nicefish-zuul-server/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM http://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven2 Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" 124 | FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO ( 125 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 126 | ) 127 | 128 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 129 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 130 | if exist %WRAPPER_JAR% ( 131 | echo Found %WRAPPER_JAR% 132 | ) else ( 133 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 134 | echo Downloading from: %DOWNLOAD_URL% 135 | powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')" 136 | echo Finished downloading %WRAPPER_JAR% 137 | ) 138 | @REM End of extension 139 | 140 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 141 | if ERRORLEVEL 1 goto error 142 | goto end 143 | 144 | :error 145 | set ERROR_CODE=1 146 | 147 | :end 148 | @endlocal & set ERROR_CODE=%ERROR_CODE% 149 | 150 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 151 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 152 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 153 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 154 | :skipRcPost 155 | 156 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 157 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 158 | 159 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 160 | 161 | exit /B %ERROR_CODE% 162 | -------------------------------------------------------------------------------- /config/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | cloud: 3 | consul: 4 | host: 127.0.0.1 5 | port: 8500 6 | discovery: 7 | register: true 8 | hostname: localhost 9 | serviceName: ${spring.application.name} 10 | healthCheckPath: /health 11 | healthCheckInterval: 15s 12 | tags: ${spring.application.name} 13 | instanceId: ${spring.application.name}:${vcap.application.instance_id:${spring.application.instance_id:${random.value}}} 14 | datasource: 15 | driverClassName: com.mysql.jdbc.Driver 16 | url: "jdbc:mysql://localhost:3306/nicefish?autoreconnect=true" 17 | password: "root" 18 | username: "root" 19 | testOnBorrow: true 20 | testWhileIdle: true 21 | timeBetweenEvictionRunsMillis: 60000 22 | minEvictableIdleTimeMillis: 30000 23 | validationQuery: SELECT 1 24 | max-active: 15 25 | max-idle: 10 26 | max-wait: 8000 27 | type: "com.alibaba.druid.pool.DruidDataSource" 28 | druid: 29 | initial-size: 5 30 | min-idle: 5 31 | maxActive: 20 32 | maxWait: 60000 33 | timeBetweenEvictionRunsMillis: 60000 34 | minEvictableIdleTimeMillis: 300000 35 | validationQuery: "SELECT 1 FROM DUAL" 36 | testWhileIdle: true 37 | testOnBorrow: false 38 | testOnReturn: false 39 | poolPreparedStatements: true 40 | maxPoolPreparedStatementPerConnectionSize: 20 41 | filters: "stat,wall,log4j" 42 | connectionProperties: "druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000" 43 | web-stat-filter: 44 | enabled: true 45 | url-pattern: "/*" 46 | exclusions: "*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*" 47 | stat-view-servlet: 48 | url-pattern: "/druid/*" 49 | allow: "127.0.0.1,192.168.163.1" 50 | deny: "192.168.1.73" 51 | reset-enable: false 52 | login-username: "admin" 53 | login-password: "123456" 54 | jpa: 55 | properties: 56 | hibernate: 57 | hbm2ddl: 58 | auto: validate 59 | dialect: org.hibernate.dialect.MySQL5InnoDBDialect 60 | show-sql: true 61 | security: 62 | oauth2: 63 | resource: 64 | jwt: 65 | key-value: | 66 | -----BEGIN PUBLIC KEY----- 67 | MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvNbZCFkfl0OkLu0Q+yhY 68 | qlBZ+mrCiOEuPqDyrxJ552Zy+LJFmrGfO+6SqbwreAORy0YjkFFFexNomRv+XJQN 69 | A83DOKmkiyp41fazVwupzQo/9XThaY8NJMye0CAfQ3Bgr5zxStUbT8zCbdzVxsFv 70 | /+JSRU91HFSkWzntsuY09jHfErR97HCvZHDnaCRp8QEVz96XCh5CRvLb/+kI5Hc9 71 | WqOrmmlsU4u13x5ykGBIeOMXhR58Et+PFV7a/JcUyZwujM9luYBHJxfDktUJQw5o 72 | dsa+rPNf3tTJi7JZV8RAsS1TfXYu6mZwGG76Pn+1vDl7Uo36rw0OYXoW+ITbx3VL 73 | aQIDAQAB 74 | -----END PUBLIC KEY----- 75 | 76 | config: 77 | oauth2: 78 | clientId: fish 79 | clientSecret: fish 80 | accessTokenValiditySeconds: 3600 81 | refreshTokenValiditySeconds: 18000 82 | privateKey: | 83 | -----BEGIN RSA PRIVATE KEY----- 84 | MIIEpAIBAAKCAQEAvNbZCFkfl0OkLu0Q+yhYqlBZ+mrCiOEuPqDyrxJ552Zy+LJF 85 | mrGfO+6SqbwreAORy0YjkFFFexNomRv+XJQNA83DOKmkiyp41fazVwupzQo/9XTh 86 | aY8NJMye0CAfQ3Bgr5zxStUbT8zCbdzVxsFv/+JSRU91HFSkWzntsuY09jHfErR9 87 | 7HCvZHDnaCRp8QEVz96XCh5CRvLb/+kI5Hc9WqOrmmlsU4u13x5ykGBIeOMXhR58 88 | Et+PFV7a/JcUyZwujM9luYBHJxfDktUJQw5odsa+rPNf3tTJi7JZV8RAsS1TfXYu 89 | 6mZwGG76Pn+1vDl7Uo36rw0OYXoW+ITbx3VLaQIDAQABAoIBADFQvm8Sr1BWhtsG 90 | aCffGoCn6Uefd9w9SlFqwNX9sj4/IAlYrRrABkClhkGzdXqrG/kFASagQs/oeql5 91 | iQzuURPMOY5jpyf82H+wJJe34Qk+AwP8GR3zENCqa1MZAHEhOO7DwrPzQWWuqJv+ 92 | TwnP3IrrtOaK4J+cbyuvziapPe2JF6L9tHwlbhMlkpgbssnEl1L1Azqs9YC1Ij6t 93 | 0vBIRivUnkFS+pCVQ9NrP+oRRmTw0LL5YPwXc6tX3v6n+7HHDXjXR/HpIx6N1C4u 94 | m2sfCvWCPEl4k0YxBW77800EFBomh4lNofHBUKg/OUDYRO8eN7lt5LRI4a7Istav 95 | 4rTjaC0CgYEA599s1+AvL6OkLGbmwgpVUeVEo4AwxdW1/TfbwH0v/y3g4JSCOH+G 96 | 7i2apdx0Sqwn6aQ8HWM8XV4eN80j0MjmtY1uGIPqvf6iO0TSKQ5JFXZAeb/L3379 97 | 7ZF0De+idoGi9ExgJhx+zrJjNzqjUm2TFf46rUGBa3bXeNejiMVBRwMCgYEA0H0b 98 | DYMYd4higVU9EvX7XlS0sVsbghJG89CPzxSW2wi3VY/DooVy4Irz8m+q1DqugCI3 99 | 0s9mpjWAeLpJks2eC5WDe6Zg4mo2swneDlrBnRBkQjVfMUv8cECkqQ6a1xc5k0qt 100 | Equpsx1xfwRBxivi22FfykL/Rj53k0NvuuSOMiMCgYEAm0jj6cb3kt3yqtHXJIgr 101 | D4eNajoFb9hp4sUv5D9yj2C4Q27xrsipIoVkFkQHlaKpsC0PHVdCK/1GG3TE0aRZ 102 | 7ahj3QMriEYpe6vhWyF4DGl/UIoEDQ9NG3bX1CVyFg9HhHhJw/w9aEvLakdY7XD4 103 | mjgCL9m4xLF4KDOyD3ya9OUCgYB0NrhEsOWLg6987jmL/ydt7oOGNQXBXFTGhWQU 104 | ByML1vDytZ9UUVS2i13trocno8ovTGOXk9phHYOOSDDIrurBBEd1PknVC2WQKRjp 105 | IXe5CDEKott8DCIbpDzkq2puKNkEHGUa+isu12OzbHkJcN8UcFPH186ZpipbIQT/ 106 | xXTpxwKBgQDZzfXRGqAmuukz5MjcbvN77u6eTkXASdSKC3nNyWMmTJ1Wn8DU1XcA 107 | AiWKiy73TUCfwJx5pdg0/tthnf0ztKeqrbxeS/uU1xkov/YfgOQoJtdJpIVgvYgq 108 | zzX/lQCVBl3kod4zAsvprbp5wc6cE0YiPVl8JRNKqu0YoqPxd35nHg== 109 | -----END RSA PRIVATE KEY----- 110 | publicKey: | 111 | -----BEGIN PUBLIC KEY----- 112 | MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvNbZCFkfl0OkLu0Q+yhY 113 | qlBZ+mrCiOEuPqDyrxJ552Zy+LJFmrGfO+6SqbwreAORy0YjkFFFexNomRv+XJQN 114 | A83DOKmkiyp41fazVwupzQo/9XThaY8NJMye0CAfQ3Bgr5zxStUbT8zCbdzVxsFv 115 | /+JSRU91HFSkWzntsuY09jHfErR97HCvZHDnaCRp8QEVz96XCh5CRvLb/+kI5Hc9 116 | WqOrmmlsU4u13x5ykGBIeOMXhR58Et+PFV7a/JcUyZwujM9luYBHJxfDktUJQw5o 117 | dsa+rPNf3tTJi7JZV8RAsS1TfXYu6mZwGG76Pn+1vDl7Uo36rw0OYXoW+ITbx3VL 118 | aQIDAQAB 119 | -----END PUBLIC KEY----- 120 | 121 | zuul: 122 | sensitive-headers: Cookie, Set-Cookie 123 | host: 124 | connect-timeout-millis: 60000 125 | socket-timeout-millis: 60000 126 | routes: 127 | oauth: 128 | path: /oauth/** 129 | serviceId: nicefish-oauth2-jwt 130 | stripPrefix: false 131 | users: 132 | path: /users/** 133 | serviceId: nicefish-user-center 134 | stripPrefix: false 135 | blog: 136 | path: /blog/** 137 | serviceId: nicefish-blog 138 | stripPrefix: false 139 | ignored-patterns: /**/hs,/**/health 140 | ratelimit: 141 | enabled: true 142 | repository: IN_MEMORY 143 | policies: 144 | api: 145 | limit: 3 146 | refresh-interval: 60 147 | type: URL 148 | redis: 149 | database: 0 150 | host: 127.0.0.1 151 | port: 6379 152 | password: 153 | timeout: 0 154 | pool: 155 | max-active: 8 156 | max-wait: -1 157 | max-idle: 8 158 | min-idle: 0 159 | 160 | turbine: 161 | aggregator: 162 | clusterConfig: nicefish-zuul-server 163 | appConfig: nicefish-zuul-server -------------------------------------------------------------------------------- /nicefish-blog/mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven2 Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /etc/mavenrc ] ; then 40 | . /etc/mavenrc 41 | fi 42 | 43 | if [ -f "$HOME/.mavenrc" ] ; then 44 | . "$HOME/.mavenrc" 45 | fi 46 | 47 | fi 48 | 49 | # OS specific support. $var _must_ be set to either true or false. 50 | cygwin=false; 51 | darwin=false; 52 | mingw=false 53 | case "`uname`" in 54 | CYGWIN*) cygwin=true ;; 55 | MINGW*) mingw=true;; 56 | Darwin*) darwin=true 57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 59 | if [ -z "$JAVA_HOME" ]; then 60 | if [ -x "/usr/libexec/java_home" ]; then 61 | export JAVA_HOME="`/usr/libexec/java_home`" 62 | else 63 | export JAVA_HOME="/Library/Java/Home" 64 | fi 65 | fi 66 | ;; 67 | esac 68 | 69 | if [ -z "$JAVA_HOME" ] ; then 70 | if [ -r /etc/gentoo-release ] ; then 71 | JAVA_HOME=`java-config --jre-home` 72 | fi 73 | fi 74 | 75 | if [ -z "$M2_HOME" ] ; then 76 | ## resolve links - $0 may be a link to maven's home 77 | PRG="$0" 78 | 79 | # need this for relative symlinks 80 | while [ -h "$PRG" ] ; do 81 | ls=`ls -ld "$PRG"` 82 | link=`expr "$ls" : '.*-> \(.*\)$'` 83 | if expr "$link" : '/.*' > /dev/null; then 84 | PRG="$link" 85 | else 86 | PRG="`dirname "$PRG"`/$link" 87 | fi 88 | done 89 | 90 | saveddir=`pwd` 91 | 92 | M2_HOME=`dirname "$PRG"`/.. 93 | 94 | # make it fully qualified 95 | M2_HOME=`cd "$M2_HOME" && pwd` 96 | 97 | cd "$saveddir" 98 | # echo Using m2 at $M2_HOME 99 | fi 100 | 101 | # For Cygwin, ensure paths are in UNIX format before anything is touched 102 | if $cygwin ; then 103 | [ -n "$M2_HOME" ] && 104 | M2_HOME=`cygpath --unix "$M2_HOME"` 105 | [ -n "$JAVA_HOME" ] && 106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 107 | [ -n "$CLASSPATH" ] && 108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 109 | fi 110 | 111 | # For Mingw, ensure paths are in UNIX format before anything is touched 112 | if $mingw ; then 113 | [ -n "$M2_HOME" ] && 114 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 115 | [ -n "$JAVA_HOME" ] && 116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 117 | # TODO classpath? 118 | fi 119 | 120 | if [ -z "$JAVA_HOME" ]; then 121 | javaExecutable="`which javac`" 122 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 123 | # readlink(1) is not available as standard on Solaris 10. 124 | readLink=`which readlink` 125 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 126 | if $darwin ; then 127 | javaHome="`dirname \"$javaExecutable\"`" 128 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 129 | else 130 | javaExecutable="`readlink -f \"$javaExecutable\"`" 131 | fi 132 | javaHome="`dirname \"$javaExecutable\"`" 133 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 134 | JAVA_HOME="$javaHome" 135 | export JAVA_HOME 136 | fi 137 | fi 138 | fi 139 | 140 | if [ -z "$JAVACMD" ] ; then 141 | if [ -n "$JAVA_HOME" ] ; then 142 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 143 | # IBM's JDK on AIX uses strange locations for the executables 144 | JAVACMD="$JAVA_HOME/jre/sh/java" 145 | else 146 | JAVACMD="$JAVA_HOME/bin/java" 147 | fi 148 | else 149 | JAVACMD="`which java`" 150 | fi 151 | fi 152 | 153 | if [ ! -x "$JAVACMD" ] ; then 154 | echo "Error: JAVA_HOME is not defined correctly." >&2 155 | echo " We cannot execute $JAVACMD" >&2 156 | exit 1 157 | fi 158 | 159 | if [ -z "$JAVA_HOME" ] ; then 160 | echo "Warning: JAVA_HOME environment variable is not set." 161 | fi 162 | 163 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 164 | 165 | # traverses directory structure from process work directory to filesystem root 166 | # first directory with .mvn subdirectory is considered project base directory 167 | find_maven_basedir() { 168 | 169 | if [ -z "$1" ] 170 | then 171 | echo "Path not specified to find_maven_basedir" 172 | return 1 173 | fi 174 | 175 | basedir="$1" 176 | wdir="$1" 177 | while [ "$wdir" != '/' ] ; do 178 | if [ -d "$wdir"/.mvn ] ; then 179 | basedir=$wdir 180 | break 181 | fi 182 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 183 | if [ -d "${wdir}" ]; then 184 | wdir=`cd "$wdir/.."; pwd` 185 | fi 186 | # end of workaround 187 | done 188 | echo "${basedir}" 189 | } 190 | 191 | # concatenates all lines of a file 192 | concat_lines() { 193 | if [ -f "$1" ]; then 194 | echo "$(tr -s '\n' ' ' < "$1")" 195 | fi 196 | } 197 | 198 | BASE_DIR=`find_maven_basedir "$(pwd)"` 199 | if [ -z "$BASE_DIR" ]; then 200 | exit 1; 201 | fi 202 | 203 | ########################################################################################## 204 | # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 205 | # This allows using the maven wrapper in projects that prohibit checking in binary data. 206 | ########################################################################################## 207 | if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then 208 | if [ "$MVNW_VERBOSE" = true ]; then 209 | echo "Found .mvn/wrapper/maven-wrapper.jar" 210 | fi 211 | else 212 | if [ "$MVNW_VERBOSE" = true ]; then 213 | echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." 214 | fi 215 | jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" 216 | while IFS="=" read key value; do 217 | case "$key" in (wrapperUrl) jarUrl="$value"; break ;; 218 | esac 219 | done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" 220 | if [ "$MVNW_VERBOSE" = true ]; then 221 | echo "Downloading from: $jarUrl" 222 | fi 223 | wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" 224 | 225 | if command -v wget > /dev/null; then 226 | if [ "$MVNW_VERBOSE" = true ]; then 227 | echo "Found wget ... using wget" 228 | fi 229 | wget "$jarUrl" -O "$wrapperJarPath" 230 | elif command -v curl > /dev/null; then 231 | if [ "$MVNW_VERBOSE" = true ]; then 232 | echo "Found curl ... using curl" 233 | fi 234 | curl -o "$wrapperJarPath" "$jarUrl" 235 | else 236 | if [ "$MVNW_VERBOSE" = true ]; then 237 | echo "Falling back to using Java to download" 238 | fi 239 | javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" 240 | if [ -e "$javaClass" ]; then 241 | if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 242 | if [ "$MVNW_VERBOSE" = true ]; then 243 | echo " - Compiling MavenWrapperDownloader.java ..." 244 | fi 245 | # Compiling the Java class 246 | ("$JAVA_HOME/bin/javac" "$javaClass") 247 | fi 248 | if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 249 | # Running the downloader 250 | if [ "$MVNW_VERBOSE" = true ]; then 251 | echo " - Running MavenWrapperDownloader.java ..." 252 | fi 253 | ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") 254 | fi 255 | fi 256 | fi 257 | fi 258 | ########################################################################################## 259 | # End of extension 260 | ########################################################################################## 261 | 262 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 263 | if [ "$MVNW_VERBOSE" = true ]; then 264 | echo $MAVEN_PROJECTBASEDIR 265 | fi 266 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 267 | 268 | # For Cygwin, switch paths to Windows format before running java 269 | if $cygwin; then 270 | [ -n "$M2_HOME" ] && 271 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 272 | [ -n "$JAVA_HOME" ] && 273 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 274 | [ -n "$CLASSPATH" ] && 275 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 276 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 277 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 278 | fi 279 | 280 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 281 | 282 | exec "$JAVACMD" \ 283 | $MAVEN_OPTS \ 284 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 285 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 286 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 287 | -------------------------------------------------------------------------------- /nicefish-oauth2-jwt/mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven2 Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /etc/mavenrc ] ; then 40 | . /etc/mavenrc 41 | fi 42 | 43 | if [ -f "$HOME/.mavenrc" ] ; then 44 | . "$HOME/.mavenrc" 45 | fi 46 | 47 | fi 48 | 49 | # OS specific support. $var _must_ be set to either true or false. 50 | cygwin=false; 51 | darwin=false; 52 | mingw=false 53 | case "`uname`" in 54 | CYGWIN*) cygwin=true ;; 55 | MINGW*) mingw=true;; 56 | Darwin*) darwin=true 57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 59 | if [ -z "$JAVA_HOME" ]; then 60 | if [ -x "/usr/libexec/java_home" ]; then 61 | export JAVA_HOME="`/usr/libexec/java_home`" 62 | else 63 | export JAVA_HOME="/Library/Java/Home" 64 | fi 65 | fi 66 | ;; 67 | esac 68 | 69 | if [ -z "$JAVA_HOME" ] ; then 70 | if [ -r /etc/gentoo-release ] ; then 71 | JAVA_HOME=`java-config --jre-home` 72 | fi 73 | fi 74 | 75 | if [ -z "$M2_HOME" ] ; then 76 | ## resolve links - $0 may be a link to maven's home 77 | PRG="$0" 78 | 79 | # need this for relative symlinks 80 | while [ -h "$PRG" ] ; do 81 | ls=`ls -ld "$PRG"` 82 | link=`expr "$ls" : '.*-> \(.*\)$'` 83 | if expr "$link" : '/.*' > /dev/null; then 84 | PRG="$link" 85 | else 86 | PRG="`dirname "$PRG"`/$link" 87 | fi 88 | done 89 | 90 | saveddir=`pwd` 91 | 92 | M2_HOME=`dirname "$PRG"`/.. 93 | 94 | # make it fully qualified 95 | M2_HOME=`cd "$M2_HOME" && pwd` 96 | 97 | cd "$saveddir" 98 | # echo Using m2 at $M2_HOME 99 | fi 100 | 101 | # For Cygwin, ensure paths are in UNIX format before anything is touched 102 | if $cygwin ; then 103 | [ -n "$M2_HOME" ] && 104 | M2_HOME=`cygpath --unix "$M2_HOME"` 105 | [ -n "$JAVA_HOME" ] && 106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 107 | [ -n "$CLASSPATH" ] && 108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 109 | fi 110 | 111 | # For Mingw, ensure paths are in UNIX format before anything is touched 112 | if $mingw ; then 113 | [ -n "$M2_HOME" ] && 114 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 115 | [ -n "$JAVA_HOME" ] && 116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 117 | # TODO classpath? 118 | fi 119 | 120 | if [ -z "$JAVA_HOME" ]; then 121 | javaExecutable="`which javac`" 122 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 123 | # readlink(1) is not available as standard on Solaris 10. 124 | readLink=`which readlink` 125 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 126 | if $darwin ; then 127 | javaHome="`dirname \"$javaExecutable\"`" 128 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 129 | else 130 | javaExecutable="`readlink -f \"$javaExecutable\"`" 131 | fi 132 | javaHome="`dirname \"$javaExecutable\"`" 133 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 134 | JAVA_HOME="$javaHome" 135 | export JAVA_HOME 136 | fi 137 | fi 138 | fi 139 | 140 | if [ -z "$JAVACMD" ] ; then 141 | if [ -n "$JAVA_HOME" ] ; then 142 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 143 | # IBM's JDK on AIX uses strange locations for the executables 144 | JAVACMD="$JAVA_HOME/jre/sh/java" 145 | else 146 | JAVACMD="$JAVA_HOME/bin/java" 147 | fi 148 | else 149 | JAVACMD="`which java`" 150 | fi 151 | fi 152 | 153 | if [ ! -x "$JAVACMD" ] ; then 154 | echo "Error: JAVA_HOME is not defined correctly." >&2 155 | echo " We cannot execute $JAVACMD" >&2 156 | exit 1 157 | fi 158 | 159 | if [ -z "$JAVA_HOME" ] ; then 160 | echo "Warning: JAVA_HOME environment variable is not set." 161 | fi 162 | 163 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 164 | 165 | # traverses directory structure from process work directory to filesystem root 166 | # first directory with .mvn subdirectory is considered project base directory 167 | find_maven_basedir() { 168 | 169 | if [ -z "$1" ] 170 | then 171 | echo "Path not specified to find_maven_basedir" 172 | return 1 173 | fi 174 | 175 | basedir="$1" 176 | wdir="$1" 177 | while [ "$wdir" != '/' ] ; do 178 | if [ -d "$wdir"/.mvn ] ; then 179 | basedir=$wdir 180 | break 181 | fi 182 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 183 | if [ -d "${wdir}" ]; then 184 | wdir=`cd "$wdir/.."; pwd` 185 | fi 186 | # end of workaround 187 | done 188 | echo "${basedir}" 189 | } 190 | 191 | # concatenates all lines of a file 192 | concat_lines() { 193 | if [ -f "$1" ]; then 194 | echo "$(tr -s '\n' ' ' < "$1")" 195 | fi 196 | } 197 | 198 | BASE_DIR=`find_maven_basedir "$(pwd)"` 199 | if [ -z "$BASE_DIR" ]; then 200 | exit 1; 201 | fi 202 | 203 | ########################################################################################## 204 | # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 205 | # This allows using the maven wrapper in projects that prohibit checking in binary data. 206 | ########################################################################################## 207 | if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then 208 | if [ "$MVNW_VERBOSE" = true ]; then 209 | echo "Found .mvn/wrapper/maven-wrapper.jar" 210 | fi 211 | else 212 | if [ "$MVNW_VERBOSE" = true ]; then 213 | echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." 214 | fi 215 | jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" 216 | while IFS="=" read key value; do 217 | case "$key" in (wrapperUrl) jarUrl="$value"; break ;; 218 | esac 219 | done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" 220 | if [ "$MVNW_VERBOSE" = true ]; then 221 | echo "Downloading from: $jarUrl" 222 | fi 223 | wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" 224 | 225 | if command -v wget > /dev/null; then 226 | if [ "$MVNW_VERBOSE" = true ]; then 227 | echo "Found wget ... using wget" 228 | fi 229 | wget "$jarUrl" -O "$wrapperJarPath" 230 | elif command -v curl > /dev/null; then 231 | if [ "$MVNW_VERBOSE" = true ]; then 232 | echo "Found curl ... using curl" 233 | fi 234 | curl -o "$wrapperJarPath" "$jarUrl" 235 | else 236 | if [ "$MVNW_VERBOSE" = true ]; then 237 | echo "Falling back to using Java to download" 238 | fi 239 | javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" 240 | if [ -e "$javaClass" ]; then 241 | if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 242 | if [ "$MVNW_VERBOSE" = true ]; then 243 | echo " - Compiling MavenWrapperDownloader.java ..." 244 | fi 245 | # Compiling the Java class 246 | ("$JAVA_HOME/bin/javac" "$javaClass") 247 | fi 248 | if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 249 | # Running the downloader 250 | if [ "$MVNW_VERBOSE" = true ]; then 251 | echo " - Running MavenWrapperDownloader.java ..." 252 | fi 253 | ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") 254 | fi 255 | fi 256 | fi 257 | fi 258 | ########################################################################################## 259 | # End of extension 260 | ########################################################################################## 261 | 262 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 263 | if [ "$MVNW_VERBOSE" = true ]; then 264 | echo $MAVEN_PROJECTBASEDIR 265 | fi 266 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 267 | 268 | # For Cygwin, switch paths to Windows format before running java 269 | if $cygwin; then 270 | [ -n "$M2_HOME" ] && 271 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 272 | [ -n "$JAVA_HOME" ] && 273 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 274 | [ -n "$CLASSPATH" ] && 275 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 276 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 277 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 278 | fi 279 | 280 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 281 | 282 | exec "$JAVACMD" \ 283 | $MAVEN_OPTS \ 284 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 285 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 286 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 287 | -------------------------------------------------------------------------------- /nicefish-swagger2-api/mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven2 Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /etc/mavenrc ] ; then 40 | . /etc/mavenrc 41 | fi 42 | 43 | if [ -f "$HOME/.mavenrc" ] ; then 44 | . "$HOME/.mavenrc" 45 | fi 46 | 47 | fi 48 | 49 | # OS specific support. $var _must_ be set to either true or false. 50 | cygwin=false; 51 | darwin=false; 52 | mingw=false 53 | case "`uname`" in 54 | CYGWIN*) cygwin=true ;; 55 | MINGW*) mingw=true;; 56 | Darwin*) darwin=true 57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 59 | if [ -z "$JAVA_HOME" ]; then 60 | if [ -x "/usr/libexec/java_home" ]; then 61 | export JAVA_HOME="`/usr/libexec/java_home`" 62 | else 63 | export JAVA_HOME="/Library/Java/Home" 64 | fi 65 | fi 66 | ;; 67 | esac 68 | 69 | if [ -z "$JAVA_HOME" ] ; then 70 | if [ -r /etc/gentoo-release ] ; then 71 | JAVA_HOME=`java-config --jre-home` 72 | fi 73 | fi 74 | 75 | if [ -z "$M2_HOME" ] ; then 76 | ## resolve links - $0 may be a link to maven's home 77 | PRG="$0" 78 | 79 | # need this for relative symlinks 80 | while [ -h "$PRG" ] ; do 81 | ls=`ls -ld "$PRG"` 82 | link=`expr "$ls" : '.*-> \(.*\)$'` 83 | if expr "$link" : '/.*' > /dev/null; then 84 | PRG="$link" 85 | else 86 | PRG="`dirname "$PRG"`/$link" 87 | fi 88 | done 89 | 90 | saveddir=`pwd` 91 | 92 | M2_HOME=`dirname "$PRG"`/.. 93 | 94 | # make it fully qualified 95 | M2_HOME=`cd "$M2_HOME" && pwd` 96 | 97 | cd "$saveddir" 98 | # echo Using m2 at $M2_HOME 99 | fi 100 | 101 | # For Cygwin, ensure paths are in UNIX format before anything is touched 102 | if $cygwin ; then 103 | [ -n "$M2_HOME" ] && 104 | M2_HOME=`cygpath --unix "$M2_HOME"` 105 | [ -n "$JAVA_HOME" ] && 106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 107 | [ -n "$CLASSPATH" ] && 108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 109 | fi 110 | 111 | # For Mingw, ensure paths are in UNIX format before anything is touched 112 | if $mingw ; then 113 | [ -n "$M2_HOME" ] && 114 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 115 | [ -n "$JAVA_HOME" ] && 116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 117 | # TODO classpath? 118 | fi 119 | 120 | if [ -z "$JAVA_HOME" ]; then 121 | javaExecutable="`which javac`" 122 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 123 | # readlink(1) is not available as standard on Solaris 10. 124 | readLink=`which readlink` 125 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 126 | if $darwin ; then 127 | javaHome="`dirname \"$javaExecutable\"`" 128 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 129 | else 130 | javaExecutable="`readlink -f \"$javaExecutable\"`" 131 | fi 132 | javaHome="`dirname \"$javaExecutable\"`" 133 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 134 | JAVA_HOME="$javaHome" 135 | export JAVA_HOME 136 | fi 137 | fi 138 | fi 139 | 140 | if [ -z "$JAVACMD" ] ; then 141 | if [ -n "$JAVA_HOME" ] ; then 142 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 143 | # IBM's JDK on AIX uses strange locations for the executables 144 | JAVACMD="$JAVA_HOME/jre/sh/java" 145 | else 146 | JAVACMD="$JAVA_HOME/bin/java" 147 | fi 148 | else 149 | JAVACMD="`which java`" 150 | fi 151 | fi 152 | 153 | if [ ! -x "$JAVACMD" ] ; then 154 | echo "Error: JAVA_HOME is not defined correctly." >&2 155 | echo " We cannot execute $JAVACMD" >&2 156 | exit 1 157 | fi 158 | 159 | if [ -z "$JAVA_HOME" ] ; then 160 | echo "Warning: JAVA_HOME environment variable is not set." 161 | fi 162 | 163 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 164 | 165 | # traverses directory structure from process work directory to filesystem root 166 | # first directory with .mvn subdirectory is considered project base directory 167 | find_maven_basedir() { 168 | 169 | if [ -z "$1" ] 170 | then 171 | echo "Path not specified to find_maven_basedir" 172 | return 1 173 | fi 174 | 175 | basedir="$1" 176 | wdir="$1" 177 | while [ "$wdir" != '/' ] ; do 178 | if [ -d "$wdir"/.mvn ] ; then 179 | basedir=$wdir 180 | break 181 | fi 182 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 183 | if [ -d "${wdir}" ]; then 184 | wdir=`cd "$wdir/.."; pwd` 185 | fi 186 | # end of workaround 187 | done 188 | echo "${basedir}" 189 | } 190 | 191 | # concatenates all lines of a file 192 | concat_lines() { 193 | if [ -f "$1" ]; then 194 | echo "$(tr -s '\n' ' ' < "$1")" 195 | fi 196 | } 197 | 198 | BASE_DIR=`find_maven_basedir "$(pwd)"` 199 | if [ -z "$BASE_DIR" ]; then 200 | exit 1; 201 | fi 202 | 203 | ########################################################################################## 204 | # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 205 | # This allows using the maven wrapper in projects that prohibit checking in binary data. 206 | ########################################################################################## 207 | if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then 208 | if [ "$MVNW_VERBOSE" = true ]; then 209 | echo "Found .mvn/wrapper/maven-wrapper.jar" 210 | fi 211 | else 212 | if [ "$MVNW_VERBOSE" = true ]; then 213 | echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." 214 | fi 215 | jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" 216 | while IFS="=" read key value; do 217 | case "$key" in (wrapperUrl) jarUrl="$value"; break ;; 218 | esac 219 | done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" 220 | if [ "$MVNW_VERBOSE" = true ]; then 221 | echo "Downloading from: $jarUrl" 222 | fi 223 | wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" 224 | 225 | if command -v wget > /dev/null; then 226 | if [ "$MVNW_VERBOSE" = true ]; then 227 | echo "Found wget ... using wget" 228 | fi 229 | wget "$jarUrl" -O "$wrapperJarPath" 230 | elif command -v curl > /dev/null; then 231 | if [ "$MVNW_VERBOSE" = true ]; then 232 | echo "Found curl ... using curl" 233 | fi 234 | curl -o "$wrapperJarPath" "$jarUrl" 235 | else 236 | if [ "$MVNW_VERBOSE" = true ]; then 237 | echo "Falling back to using Java to download" 238 | fi 239 | javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" 240 | if [ -e "$javaClass" ]; then 241 | if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 242 | if [ "$MVNW_VERBOSE" = true ]; then 243 | echo " - Compiling MavenWrapperDownloader.java ..." 244 | fi 245 | # Compiling the Java class 246 | ("$JAVA_HOME/bin/javac" "$javaClass") 247 | fi 248 | if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 249 | # Running the downloader 250 | if [ "$MVNW_VERBOSE" = true ]; then 251 | echo " - Running MavenWrapperDownloader.java ..." 252 | fi 253 | ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") 254 | fi 255 | fi 256 | fi 257 | fi 258 | ########################################################################################## 259 | # End of extension 260 | ########################################################################################## 261 | 262 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 263 | if [ "$MVNW_VERBOSE" = true ]; then 264 | echo $MAVEN_PROJECTBASEDIR 265 | fi 266 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 267 | 268 | # For Cygwin, switch paths to Windows format before running java 269 | if $cygwin; then 270 | [ -n "$M2_HOME" ] && 271 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 272 | [ -n "$JAVA_HOME" ] && 273 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 274 | [ -n "$CLASSPATH" ] && 275 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 276 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 277 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 278 | fi 279 | 280 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 281 | 282 | exec "$JAVACMD" \ 283 | $MAVEN_OPTS \ 284 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 285 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 286 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 287 | -------------------------------------------------------------------------------- /nicefish-user-center/mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven2 Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /etc/mavenrc ] ; then 40 | . /etc/mavenrc 41 | fi 42 | 43 | if [ -f "$HOME/.mavenrc" ] ; then 44 | . "$HOME/.mavenrc" 45 | fi 46 | 47 | fi 48 | 49 | # OS specific support. $var _must_ be set to either true or false. 50 | cygwin=false; 51 | darwin=false; 52 | mingw=false 53 | case "`uname`" in 54 | CYGWIN*) cygwin=true ;; 55 | MINGW*) mingw=true;; 56 | Darwin*) darwin=true 57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 59 | if [ -z "$JAVA_HOME" ]; then 60 | if [ -x "/usr/libexec/java_home" ]; then 61 | export JAVA_HOME="`/usr/libexec/java_home`" 62 | else 63 | export JAVA_HOME="/Library/Java/Home" 64 | fi 65 | fi 66 | ;; 67 | esac 68 | 69 | if [ -z "$JAVA_HOME" ] ; then 70 | if [ -r /etc/gentoo-release ] ; then 71 | JAVA_HOME=`java-config --jre-home` 72 | fi 73 | fi 74 | 75 | if [ -z "$M2_HOME" ] ; then 76 | ## resolve links - $0 may be a link to maven's home 77 | PRG="$0" 78 | 79 | # need this for relative symlinks 80 | while [ -h "$PRG" ] ; do 81 | ls=`ls -ld "$PRG"` 82 | link=`expr "$ls" : '.*-> \(.*\)$'` 83 | if expr "$link" : '/.*' > /dev/null; then 84 | PRG="$link" 85 | else 86 | PRG="`dirname "$PRG"`/$link" 87 | fi 88 | done 89 | 90 | saveddir=`pwd` 91 | 92 | M2_HOME=`dirname "$PRG"`/.. 93 | 94 | # make it fully qualified 95 | M2_HOME=`cd "$M2_HOME" && pwd` 96 | 97 | cd "$saveddir" 98 | # echo Using m2 at $M2_HOME 99 | fi 100 | 101 | # For Cygwin, ensure paths are in UNIX format before anything is touched 102 | if $cygwin ; then 103 | [ -n "$M2_HOME" ] && 104 | M2_HOME=`cygpath --unix "$M2_HOME"` 105 | [ -n "$JAVA_HOME" ] && 106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 107 | [ -n "$CLASSPATH" ] && 108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 109 | fi 110 | 111 | # For Mingw, ensure paths are in UNIX format before anything is touched 112 | if $mingw ; then 113 | [ -n "$M2_HOME" ] && 114 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 115 | [ -n "$JAVA_HOME" ] && 116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 117 | # TODO classpath? 118 | fi 119 | 120 | if [ -z "$JAVA_HOME" ]; then 121 | javaExecutable="`which javac`" 122 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 123 | # readlink(1) is not available as standard on Solaris 10. 124 | readLink=`which readlink` 125 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 126 | if $darwin ; then 127 | javaHome="`dirname \"$javaExecutable\"`" 128 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 129 | else 130 | javaExecutable="`readlink -f \"$javaExecutable\"`" 131 | fi 132 | javaHome="`dirname \"$javaExecutable\"`" 133 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 134 | JAVA_HOME="$javaHome" 135 | export JAVA_HOME 136 | fi 137 | fi 138 | fi 139 | 140 | if [ -z "$JAVACMD" ] ; then 141 | if [ -n "$JAVA_HOME" ] ; then 142 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 143 | # IBM's JDK on AIX uses strange locations for the executables 144 | JAVACMD="$JAVA_HOME/jre/sh/java" 145 | else 146 | JAVACMD="$JAVA_HOME/bin/java" 147 | fi 148 | else 149 | JAVACMD="`which java`" 150 | fi 151 | fi 152 | 153 | if [ ! -x "$JAVACMD" ] ; then 154 | echo "Error: JAVA_HOME is not defined correctly." >&2 155 | echo " We cannot execute $JAVACMD" >&2 156 | exit 1 157 | fi 158 | 159 | if [ -z "$JAVA_HOME" ] ; then 160 | echo "Warning: JAVA_HOME environment variable is not set." 161 | fi 162 | 163 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 164 | 165 | # traverses directory structure from process work directory to filesystem root 166 | # first directory with .mvn subdirectory is considered project base directory 167 | find_maven_basedir() { 168 | 169 | if [ -z "$1" ] 170 | then 171 | echo "Path not specified to find_maven_basedir" 172 | return 1 173 | fi 174 | 175 | basedir="$1" 176 | wdir="$1" 177 | while [ "$wdir" != '/' ] ; do 178 | if [ -d "$wdir"/.mvn ] ; then 179 | basedir=$wdir 180 | break 181 | fi 182 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 183 | if [ -d "${wdir}" ]; then 184 | wdir=`cd "$wdir/.."; pwd` 185 | fi 186 | # end of workaround 187 | done 188 | echo "${basedir}" 189 | } 190 | 191 | # concatenates all lines of a file 192 | concat_lines() { 193 | if [ -f "$1" ]; then 194 | echo "$(tr -s '\n' ' ' < "$1")" 195 | fi 196 | } 197 | 198 | BASE_DIR=`find_maven_basedir "$(pwd)"` 199 | if [ -z "$BASE_DIR" ]; then 200 | exit 1; 201 | fi 202 | 203 | ########################################################################################## 204 | # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 205 | # This allows using the maven wrapper in projects that prohibit checking in binary data. 206 | ########################################################################################## 207 | if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then 208 | if [ "$MVNW_VERBOSE" = true ]; then 209 | echo "Found .mvn/wrapper/maven-wrapper.jar" 210 | fi 211 | else 212 | if [ "$MVNW_VERBOSE" = true ]; then 213 | echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." 214 | fi 215 | jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" 216 | while IFS="=" read key value; do 217 | case "$key" in (wrapperUrl) jarUrl="$value"; break ;; 218 | esac 219 | done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" 220 | if [ "$MVNW_VERBOSE" = true ]; then 221 | echo "Downloading from: $jarUrl" 222 | fi 223 | wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" 224 | 225 | if command -v wget > /dev/null; then 226 | if [ "$MVNW_VERBOSE" = true ]; then 227 | echo "Found wget ... using wget" 228 | fi 229 | wget "$jarUrl" -O "$wrapperJarPath" 230 | elif command -v curl > /dev/null; then 231 | if [ "$MVNW_VERBOSE" = true ]; then 232 | echo "Found curl ... using curl" 233 | fi 234 | curl -o "$wrapperJarPath" "$jarUrl" 235 | else 236 | if [ "$MVNW_VERBOSE" = true ]; then 237 | echo "Falling back to using Java to download" 238 | fi 239 | javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" 240 | if [ -e "$javaClass" ]; then 241 | if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 242 | if [ "$MVNW_VERBOSE" = true ]; then 243 | echo " - Compiling MavenWrapperDownloader.java ..." 244 | fi 245 | # Compiling the Java class 246 | ("$JAVA_HOME/bin/javac" "$javaClass") 247 | fi 248 | if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 249 | # Running the downloader 250 | if [ "$MVNW_VERBOSE" = true ]; then 251 | echo " - Running MavenWrapperDownloader.java ..." 252 | fi 253 | ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") 254 | fi 255 | fi 256 | fi 257 | fi 258 | ########################################################################################## 259 | # End of extension 260 | ########################################################################################## 261 | 262 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 263 | if [ "$MVNW_VERBOSE" = true ]; then 264 | echo $MAVEN_PROJECTBASEDIR 265 | fi 266 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 267 | 268 | # For Cygwin, switch paths to Windows format before running java 269 | if $cygwin; then 270 | [ -n "$M2_HOME" ] && 271 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 272 | [ -n "$JAVA_HOME" ] && 273 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 274 | [ -n "$CLASSPATH" ] && 275 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 276 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 277 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 278 | fi 279 | 280 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 281 | 282 | exec "$JAVACMD" \ 283 | $MAVEN_OPTS \ 284 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 285 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 286 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 287 | -------------------------------------------------------------------------------- /nicefish-zuul-server/mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven2 Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /etc/mavenrc ] ; then 40 | . /etc/mavenrc 41 | fi 42 | 43 | if [ -f "$HOME/.mavenrc" ] ; then 44 | . "$HOME/.mavenrc" 45 | fi 46 | 47 | fi 48 | 49 | # OS specific support. $var _must_ be set to either true or false. 50 | cygwin=false; 51 | darwin=false; 52 | mingw=false 53 | case "`uname`" in 54 | CYGWIN*) cygwin=true ;; 55 | MINGW*) mingw=true;; 56 | Darwin*) darwin=true 57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 59 | if [ -z "$JAVA_HOME" ]; then 60 | if [ -x "/usr/libexec/java_home" ]; then 61 | export JAVA_HOME="`/usr/libexec/java_home`" 62 | else 63 | export JAVA_HOME="/Library/Java/Home" 64 | fi 65 | fi 66 | ;; 67 | esac 68 | 69 | if [ -z "$JAVA_HOME" ] ; then 70 | if [ -r /etc/gentoo-release ] ; then 71 | JAVA_HOME=`java-config --jre-home` 72 | fi 73 | fi 74 | 75 | if [ -z "$M2_HOME" ] ; then 76 | ## resolve links - $0 may be a link to maven's home 77 | PRG="$0" 78 | 79 | # need this for relative symlinks 80 | while [ -h "$PRG" ] ; do 81 | ls=`ls -ld "$PRG"` 82 | link=`expr "$ls" : '.*-> \(.*\)$'` 83 | if expr "$link" : '/.*' > /dev/null; then 84 | PRG="$link" 85 | else 86 | PRG="`dirname "$PRG"`/$link" 87 | fi 88 | done 89 | 90 | saveddir=`pwd` 91 | 92 | M2_HOME=`dirname "$PRG"`/.. 93 | 94 | # make it fully qualified 95 | M2_HOME=`cd "$M2_HOME" && pwd` 96 | 97 | cd "$saveddir" 98 | # echo Using m2 at $M2_HOME 99 | fi 100 | 101 | # For Cygwin, ensure paths are in UNIX format before anything is touched 102 | if $cygwin ; then 103 | [ -n "$M2_HOME" ] && 104 | M2_HOME=`cygpath --unix "$M2_HOME"` 105 | [ -n "$JAVA_HOME" ] && 106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 107 | [ -n "$CLASSPATH" ] && 108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 109 | fi 110 | 111 | # For Mingw, ensure paths are in UNIX format before anything is touched 112 | if $mingw ; then 113 | [ -n "$M2_HOME" ] && 114 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 115 | [ -n "$JAVA_HOME" ] && 116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 117 | # TODO classpath? 118 | fi 119 | 120 | if [ -z "$JAVA_HOME" ]; then 121 | javaExecutable="`which javac`" 122 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 123 | # readlink(1) is not available as standard on Solaris 10. 124 | readLink=`which readlink` 125 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 126 | if $darwin ; then 127 | javaHome="`dirname \"$javaExecutable\"`" 128 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 129 | else 130 | javaExecutable="`readlink -f \"$javaExecutable\"`" 131 | fi 132 | javaHome="`dirname \"$javaExecutable\"`" 133 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 134 | JAVA_HOME="$javaHome" 135 | export JAVA_HOME 136 | fi 137 | fi 138 | fi 139 | 140 | if [ -z "$JAVACMD" ] ; then 141 | if [ -n "$JAVA_HOME" ] ; then 142 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 143 | # IBM's JDK on AIX uses strange locations for the executables 144 | JAVACMD="$JAVA_HOME/jre/sh/java" 145 | else 146 | JAVACMD="$JAVA_HOME/bin/java" 147 | fi 148 | else 149 | JAVACMD="`which java`" 150 | fi 151 | fi 152 | 153 | if [ ! -x "$JAVACMD" ] ; then 154 | echo "Error: JAVA_HOME is not defined correctly." >&2 155 | echo " We cannot execute $JAVACMD" >&2 156 | exit 1 157 | fi 158 | 159 | if [ -z "$JAVA_HOME" ] ; then 160 | echo "Warning: JAVA_HOME environment variable is not set." 161 | fi 162 | 163 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 164 | 165 | # traverses directory structure from process work directory to filesystem root 166 | # first directory with .mvn subdirectory is considered project base directory 167 | find_maven_basedir() { 168 | 169 | if [ -z "$1" ] 170 | then 171 | echo "Path not specified to find_maven_basedir" 172 | return 1 173 | fi 174 | 175 | basedir="$1" 176 | wdir="$1" 177 | while [ "$wdir" != '/' ] ; do 178 | if [ -d "$wdir"/.mvn ] ; then 179 | basedir=$wdir 180 | break 181 | fi 182 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 183 | if [ -d "${wdir}" ]; then 184 | wdir=`cd "$wdir/.."; pwd` 185 | fi 186 | # end of workaround 187 | done 188 | echo "${basedir}" 189 | } 190 | 191 | # concatenates all lines of a file 192 | concat_lines() { 193 | if [ -f "$1" ]; then 194 | echo "$(tr -s '\n' ' ' < "$1")" 195 | fi 196 | } 197 | 198 | BASE_DIR=`find_maven_basedir "$(pwd)"` 199 | if [ -z "$BASE_DIR" ]; then 200 | exit 1; 201 | fi 202 | 203 | ########################################################################################## 204 | # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 205 | # This allows using the maven wrapper in projects that prohibit checking in binary data. 206 | ########################################################################################## 207 | if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then 208 | if [ "$MVNW_VERBOSE" = true ]; then 209 | echo "Found .mvn/wrapper/maven-wrapper.jar" 210 | fi 211 | else 212 | if [ "$MVNW_VERBOSE" = true ]; then 213 | echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." 214 | fi 215 | jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" 216 | while IFS="=" read key value; do 217 | case "$key" in (wrapperUrl) jarUrl="$value"; break ;; 218 | esac 219 | done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" 220 | if [ "$MVNW_VERBOSE" = true ]; then 221 | echo "Downloading from: $jarUrl" 222 | fi 223 | wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" 224 | 225 | if command -v wget > /dev/null; then 226 | if [ "$MVNW_VERBOSE" = true ]; then 227 | echo "Found wget ... using wget" 228 | fi 229 | wget "$jarUrl" -O "$wrapperJarPath" 230 | elif command -v curl > /dev/null; then 231 | if [ "$MVNW_VERBOSE" = true ]; then 232 | echo "Found curl ... using curl" 233 | fi 234 | curl -o "$wrapperJarPath" "$jarUrl" 235 | else 236 | if [ "$MVNW_VERBOSE" = true ]; then 237 | echo "Falling back to using Java to download" 238 | fi 239 | javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" 240 | if [ -e "$javaClass" ]; then 241 | if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 242 | if [ "$MVNW_VERBOSE" = true ]; then 243 | echo " - Compiling MavenWrapperDownloader.java ..." 244 | fi 245 | # Compiling the Java class 246 | ("$JAVA_HOME/bin/javac" "$javaClass") 247 | fi 248 | if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 249 | # Running the downloader 250 | if [ "$MVNW_VERBOSE" = true ]; then 251 | echo " - Running MavenWrapperDownloader.java ..." 252 | fi 253 | ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") 254 | fi 255 | fi 256 | fi 257 | fi 258 | ########################################################################################## 259 | # End of extension 260 | ########################################################################################## 261 | 262 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 263 | if [ "$MVNW_VERBOSE" = true ]; then 264 | echo $MAVEN_PROJECTBASEDIR 265 | fi 266 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 267 | 268 | # For Cygwin, switch paths to Windows format before running java 269 | if $cygwin; then 270 | [ -n "$M2_HOME" ] && 271 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 272 | [ -n "$JAVA_HOME" ] && 273 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 274 | [ -n "$CLASSPATH" ] && 275 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 276 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 277 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 278 | fi 279 | 280 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 281 | 282 | exec "$JAVACMD" \ 283 | $MAVEN_OPTS \ 284 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 285 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 286 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 287 | --------------------------------------------------------------------------------