Browse Source

init

4.1.3.A
xfworld 8 years ago
commit
a4bd15da1f
6 changed files with 152 additions and 0 deletions
  1. +76
    -0
      build.gradle
  2. +18
    -0
      settings.gradle
  3. +41
    -0
      src/main/java/cn/afterturn/easypoi/configuration/EasyPoiAutoConfiguration.java
  4. +11
    -0
      src/main/java/cn/afterturn/easypoi/configuration/EasyPoiProperties.java
  5. +4
    -0
      src/main/java/cn/afterturn/easypoi/package-info.java
  6. +2
    -0
      src/main/resources/META-INF/spring.factories

+ 76
- 0
build.gradle View File

@@ -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'
}

+ 18
- 0
settings.gradle View File

@@ -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'

+ 41
- 0
src/main/java/cn/afterturn/easypoi/configuration/EasyPoiAutoConfiguration.java View File

@@ -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;
}


}

+ 11
- 0
src/main/java/cn/afterturn/easypoi/configuration/EasyPoiProperties.java View File

@@ -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 {

}

+ 4
- 0
src/main/java/cn/afterturn/easypoi/package-info.java View File

@@ -0,0 +1,4 @@
/**
* Created by xfworld on 2017-11-22.
**/
package cn.afterturn.easypoi;

+ 2
- 0
src/main/resources/META-INF/spring.factories View File

@@ -0,0 +1,2 @@
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
cn.afterturn.easypoi.configuration.EasyPoiAutoConfiguration

Loading…
Cancel
Save