Linux使用docker搭建Maven私有仓库_Icoolkj的博客-CSDN博客_docker搭建maven仓库
docker run --name docker-nexus3 -p 8081:8081 -v /usr/local/nexus3/nexus-data:/nexus-data -d sonatype/nexus3
===============================================================
如何自定义一个springboot starter(超详细)_johnhum123的博客-CSDN博客_springboot自定义starter
maven打包上传到私有仓库的步骤_茁壮成长的凌大大的博客-CSDN博客_maven发布到私有仓库
4.0.0
org.example
test-spring-boot-starter
0.3
spring-boot-starter-parent
org.springframework.boot
2.5.2
8
8
org.springframework.boot
spring-boot-configuration-processor
true
org.springframework.boot
spring-boot-autoconfigure
maven-releases
Nexus Release Repository
http://162.14.114.186:8081/repository/maven-releases/
maven-snapshots
Nexus Snapshot Repository
http://162.14.114.186:8081/repository/maven-snapshots/
org.apache.maven.plugins
maven-source-plugin
3.0.1
true
compile
jar
package org.example.test.spring.boot.starter;
import java.util.List;
/**
* @author Johnhum on 2021/7/18
*/
public interface ISplitService {
List split(String value);
}
package org.example.test.spring.boot.starter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
@ConditionalOnClass(value = {ISplitService.class, SplitServiceImpl.class})
public class SplitAutoConfigure {
@Bean
@ConditionalOnMissingBean
ISplitService startService() {
return new SplitServiceImpl();
}
}
package org.example.test.spring.boot.starter;
import org.springframework.util.StringUtils;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* @author Johnhum on 2021/7/18
*/
public class SplitServiceImpl implements ISplitService {
@SuppressWarnings("all")
@Override
public List split(String value) {
return Stream.of(StringUtils.split(value, ",")).collect(Collectors.toList());
}
}
\test-spring-boot-starter\test-spring-boot-starter\src\main\resources\META-INF\spring.factories
org.springframework.boot.autoconfigure.EnableAutoConfiguration=org.example.test.spring.boot.starter.SplitAutoConfigure
mvn deploy
成功上传了
======================================
4.0.0
org.springframework.boot
spring-boot-starter-parent
2.5.2
com.example
test-use-starter2
0.0.1-SNAPSHOT
test-use-starter2
test-use-starter2
1.8
org.springframework.boot
spring-boot-starter-web
org.projectlombok
lombok
true
org.springframework.boot
spring-boot-starter-test
test
com.alibaba
fastjson
2.0.3
org.example
test-spring-boot-starter
0.3
org.springframework.boot
spring-boot-maven-plugin
org.projectlombok
lombok
package com.example.testusestarter2;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class TestUseStarter2Application {
public static void main(String[] args) {
SpringApplication.run(TestUseStarter2Application.class, args);
}
}
package com.example.testusestarter2;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.example.test.spring.boot.starter.ISplitService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
@Slf4j
class TestUseStarter2ApplicationTests {
@Test
void contextLoads() {
}
@Autowired
private ISplitService splitServiceImpl;
@Test
public void splitTest() {
log.info("split context: {}", JSON.toJSONString(splitServiceImpl.split("8888,6666666666")));
}
}
===============================================================
@Configuration就是个bean工厂,工厂类中的方法就是生成bean的方法
见spring refresh和spring bean源码分析