From a4bd15da1f5020b654f1a3e7ba01e549b5798421 Mon Sep 17 00:00:00 2001 From: xfworld Date: Wed, 22 Nov 2017 17:56:46 +0800 Subject: [PATCH] init --- build.gradle | 76 +++++++++++++++++++ settings.gradle | 18 +++++ .../EasyPoiAutoConfiguration.java | 41 ++++++++++ .../configuration/EasyPoiProperties.java | 11 +++ .../cn/afterturn/easypoi/package-info.java | 4 + src/main/resources/META-INF/spring.factories | 2 + 6 files changed, 152 insertions(+) create mode 100644 build.gradle create mode 100644 settings.gradle create mode 100644 src/main/java/cn/afterturn/easypoi/configuration/EasyPoiAutoConfiguration.java create mode 100644 src/main/java/cn/afterturn/easypoi/configuration/EasyPoiProperties.java create mode 100644 src/main/java/cn/afterturn/easypoi/package-info.java create mode 100644 src/main/resources/META-INF/spring.factories diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..25fb881 --- /dev/null +++ b/build.gradle @@ -0,0 +1,76 @@ +/* + * This build file was generated by the Gradle 'init' task. + * + * This generated file contains a commented-out sample Java project to get you started. + * For more details take a look at the Java Quickstart chapter in the Gradle + * user guide available at https://docs.gradle.org/4.3.1/userguide/tutorial_java_projects.html + */ +group = 'cn.afterturn' +version = '0.1-beta' + +// Apply the java plugin to add support for Java +apply plugin: 'java' +apply plugin: 'idea' +apply plugin: "io.spring.dependency-management" + + buildscript { + ext { + springBootVersion ='1.5.8.RELEASE' + } + repositories { + maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } + mavenLocal()//maven的本地仓 + jcenter()//官方仓 + } + dependencies { + classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") + classpath("io.spring.gradle:dependency-management-plugin:1.0.3.RELEASE") + } + } + + + + // In this section you declare where to find the dependencies of your project + repositories { + // Use 'jcenter' for resolving your dependencies. + // You can declare any Maven/Ivy/file repository here. + maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } + jcenter() + } + + sourceCompatibility = 1.8 + targetCompatibility = 1.8 + [compileJava, javadoc, compileTestJava]*.options*.encoding = 'UTF-8' + + + + task sourcesJar(type: Jar, dependsOn: classes) { + classifier = 'sources' + from sourceSets.main.allSource + } + + artifacts { + archives sourcesJar + } + + ext { + springBootVersion ='1.5.8.RELEASE' + springVersion = '4.3.12.RELEASE' + } + +// In this section you declare the dependencies for your production and test code +dependencies { + // The production code uses the SLF4J logging API at compile time + compile 'org.slf4j:slf4j-api:1.7.25' + // compile group: 'io.spring.gradle', name: 'dependency-management-plugin', version: '1.0.3.RELEASE' + compile group: 'org.springframework.boot', name: 'spring-boot-autoconfigure', version: "$springBootVersion" + compile group: 'org.springframework.boot', name: 'spring-boot-configuration-processor', version: "$springBootVersion" + + compile group: 'org.springframework.boot', name: 'spring-boot-starter-web',version:"$springBootVersion" + + // Declare the dependency for your favourite test framework you want to use in your tests. + // TestNG is also supported by the Gradle Test task. Just change the + // testCompile dependency to testCompile 'org.testng:testng:6.8.1' and add + // 'test.useTestNG()' to your build script. + testCompile 'junit:junit:4.12' +} \ No newline at end of file diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..8c5bdf8 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,18 @@ +/* + * This settings file was generated by the Gradle 'init' task. + * + * The settings file is used to specify which projects to include in your build. + * In a single project build this file can be empty or even removed. + * + * Detailed information about configuring a multi-project build in Gradle can be found + * in the user guide at https://docs.gradle.org/4.3.1/userguide/multi_project_builds.html + */ + +/* +// To declare projects as part of a multi-project build use the 'include' method +include 'shared' +include 'api' +include 'services:webservice' +*/ + +rootProject.name = 'easypoi-spring-boot-starter' diff --git a/src/main/java/cn/afterturn/easypoi/configuration/EasyPoiAutoConfiguration.java b/src/main/java/cn/afterturn/easypoi/configuration/EasyPoiAutoConfiguration.java new file mode 100644 index 0000000..fc297fa --- /dev/null +++ b/src/main/java/cn/afterturn/easypoi/configuration/EasyPoiAutoConfiguration.java @@ -0,0 +1,41 @@ +package cn.afterturn.easypoi.configuration; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.view.BeanNameViewResolver; + +/** + * Created by xfworld on 2017-11-22. + **/ +@Configuration +@AutoConfigureAfter(WebMvcAutoConfiguration.class) +@EnableConfigurationProperties(EasyPoiProperties.class) +//@ConditionalOnClass +//easy.poi.base.enable 不存在默认为true,若存在==true则创建,否则==false不创建 +@ConditionalOnProperty(prefix = "easy.poi.base", name = "enable", matchIfMissing = true) +@ComponentScan(basePackages = {"cn.afterturn.easypoi.view"}) +public class EasyPoiAutoConfiguration { + + + @Autowired + private EasyPoiProperties easyPoiProperties; + + + /** + * 通过 order 属性来定义视图解析器的优先级, order 值越小优先级越高 + */ + @Bean + public BeanNameViewResolver beanNameViewResolver() { + BeanNameViewResolver resolver = new BeanNameViewResolver(); + resolver.setOrder(10); + return resolver; + } + + +} diff --git a/src/main/java/cn/afterturn/easypoi/configuration/EasyPoiProperties.java b/src/main/java/cn/afterturn/easypoi/configuration/EasyPoiProperties.java new file mode 100644 index 0000000..9087362 --- /dev/null +++ b/src/main/java/cn/afterturn/easypoi/configuration/EasyPoiProperties.java @@ -0,0 +1,11 @@ +package cn.afterturn.easypoi.configuration; + +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * Created by xfworld on 2017-11-22. + **/ +@ConfigurationProperties(prefix = "easy.poi.base") +public class EasyPoiProperties { + +} diff --git a/src/main/java/cn/afterturn/easypoi/package-info.java b/src/main/java/cn/afterturn/easypoi/package-info.java new file mode 100644 index 0000000..e581197 --- /dev/null +++ b/src/main/java/cn/afterturn/easypoi/package-info.java @@ -0,0 +1,4 @@ +/** + * Created by xfworld on 2017-11-22. + **/ +package cn.afterturn.easypoi; \ No newline at end of file diff --git a/src/main/resources/META-INF/spring.factories b/src/main/resources/META-INF/spring.factories new file mode 100644 index 0000000..7000952 --- /dev/null +++ b/src/main/resources/META-INF/spring.factories @@ -0,0 +1,2 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ +cn.afterturn.easypoi.configuration.EasyPoiAutoConfiguration \ No newline at end of file