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发布到私有仓库
- <project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0modelVersion>
-
- <groupId>org.examplegroupId>
- <artifactId>test-spring-boot-starterartifactId>
- <version>0.3version>
-
- <parent>
- <artifactId>spring-boot-starter-parentartifactId>
- <groupId>org.springframework.bootgroupId>
- <version>2.5.2version>
- parent>
-
-
- <properties>
- <maven.compiler.source>8maven.compiler.source>
- <maven.compiler.target>8maven.compiler.target>
- properties>
-
- <dependencies>
- <dependency>
- <groupId>org.springframework.bootgroupId>
- <artifactId>spring-boot-configuration-processorartifactId>
- <optional>trueoptional>
- dependency>
- <dependency>
- <groupId>org.springframework.bootgroupId>
- <artifactId>spring-boot-autoconfigureartifactId>
- dependency>
- dependencies>
-
-
- <distributionManagement>
- <repository>
- <id>maven-releasesid>
- <name>Nexus Release Repositoryname>
- <url>http://162.14.114.186:8081/repository/maven-releases/url>
- repository>
- <snapshotRepository>
- <id>maven-snapshotsid>
- <name>Nexus Snapshot Repositoryname>
- <url>http://162.14.114.186:8081/repository/maven-snapshots/url>
- snapshotRepository>
- distributionManagement>
-
- <build>
- <plugins>
-
- <plugin>
- <groupId>org.apache.maven.pluginsgroupId>
- <artifactId>maven-source-pluginartifactId>
- <version>3.0.1version>
- <configuration>
- <attach>trueattach>
- configuration>
- <executions>
- <execution>
- <phase>compilephase>
- <goals>
- <goal>jargoal>
- goals>
- execution>
- executions>
- plugin>
- plugins>
- build>
-
-
- project>
- 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
成功上传了
======================================
- <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0modelVersion>
- <parent>
- <groupId>org.springframework.bootgroupId>
- <artifactId>spring-boot-starter-parentartifactId>
- <version>2.5.2version>
- <relativePath/>
- parent>
- <groupId>com.examplegroupId>
- <artifactId>test-use-starter2artifactId>
- <version>0.0.1-SNAPSHOTversion>
- <name>test-use-starter2name>
- <description>test-use-starter2description>
- <properties>
- <java.version>1.8java.version>
- properties>
- <dependencies>
- <dependency>
- <groupId>org.springframework.bootgroupId>
- <artifactId>spring-boot-starter-webartifactId>
- dependency>
-
- <dependency>
- <groupId>org.projectlombokgroupId>
- <artifactId>lombokartifactId>
- <optional>trueoptional>
- dependency>
- <dependency>
- <groupId>org.springframework.bootgroupId>
- <artifactId>spring-boot-starter-testartifactId>
- <scope>testscope>
- dependency>
-
- <dependency>
- <groupId>com.alibabagroupId>
- <artifactId>fastjsonartifactId>
- <version>2.0.3version>
- dependency>
- <dependency>
- <groupId>org.examplegroupId>
- <artifactId>test-spring-boot-starterartifactId>
- <version>0.3version>
- dependency>
- dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.springframework.bootgroupId>
- <artifactId>spring-boot-maven-pluginartifactId>
- <configuration>
- <excludes>
- <exclude>
- <groupId>org.projectlombokgroupId>
- <artifactId>lombokartifactId>
- exclude>
- excludes>
- configuration>
- plugin>
- plugins>
- build>
-
- project>
- 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源码分析