关键词:
【中文标题】用于指定分发管理的自定义 spring boot 启动器【英文标题】:Custom spring boot starter for specifying distribution management 【发布时间】:2017-01-08 01:23:22 【问题描述】:我们有一个 Spring Boot 应用程序,它的父级定义为 spring-boot-starter-parent。但是在我们的项目中,我们有一个定义了分发管理的父pom,并且项目中的所有子模块都继承自它。现在,由于 spring boot 应用程序已经从 spring-boot-starter-parent 继承,并且我不想复制分发管理,我想有一个自定义的 spring boot starter 模块只是为了能够在那里定义分发管理然后将此自定义 Spring Boot 启动器作为依赖项包含在 Spring Boot 应用程序中。但是,当我对 Spring Boot 应用程序执行 mvn clean install deploy 时,它会失败并显示如下错误:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.
2:deploy (default-deploy) on project crs-acc-eve-gridgain-load-app: Deployment f
ailed: repository element was not specified in the POM inside distributionManage
ment element or in -DaltDeploymentRepository=id::layout::url parameter -> [Help
1]
这是实现这一目标的正确方法吗?还是有其他推荐的方法?
下面是自定义spring boot starter父模块的poms:
<?xml version="1.0" encoding="UTF-8"?>
<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">
<parent>
<artifactId>crs-micro-services</artifactId>
<groupId>com.ing.crs</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>crs-spring-boot-starter-parent</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spring-boot.version>1.3.5.RELEASE</spring-boot.version>
</properties>
<modules>
<module>crs-spring-boot-starter</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>$spring-boot.version</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<distributionManagement>
<repository>
<id>XXXX</id>
<name>XXXX</name>
<url>XXXX</url>
</repository>
<snapshotRepository>
<id>XXXX</id>
<name>XXXX</name>
<url>XXXX</url>
<uniqueVersion>false</uniqueVersion>
</snapshotRepository>
</distributionManagement>
</project>
还有这个..作为入门模块
<?xml version="1.0" encoding="UTF-8"?>
<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">
<parent>
<artifactId>crs-spring-boot-starter-parent</artifactId>
<groupId>com.ing.crs</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<version>1.0-SNAPSHOT</version>
<artifactId>crs-spring-boot-starter</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
</dependencies>
</project>
并且sprng boot应用有这个依赖
<dependency>
<groupId>com.ing.crs</groupId>
<artifactId>crs-spring-boot-starter</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>import</scope>
</dependency>
感谢和问候, 普里亚
【问题讨论】:
【参考方案1】:没有要求您的构建应使用spring-boot-starter-parent
进行配置。如果您已经有一个具有某些分发管理的父级,请随时保留它。您需要稍微调整一下父级。这里有几个选项:
spring-boot-dependencies
BOM 代替。见the documentation for more details。您必须复制您使用的父级的位(例如插件定义),但这不是一项繁重的工作。
你的提议永远不会奏效。 BOM 仅导入 <dependencyManagement>
。你要找的是 mixin,它还不被 Maven 支持。
【讨论】:
谢谢斯蒂芬,这有帮助!如何在通过 NPM 分发时管理 React 组件(Redux、CSS)的自定义方面
...定义Redux容器和CSS通常如何通过NPM处理?下面的结构不适用于NPM等传统包分发平台,因为我需要编辑自定义不同项目中的R 查看详情
Spring Boot 中的自定义异常
】SpringBoot中的自定义异常【英文标题】:CustomExceptioninSprinBoot【发布时间】:2019-12-1209:54:06【问题描述】:我在SPRINGBOOT中编写了以下自定义错误处理程序@RestControllerAdvicepublicclassCustomGlobalExceptionHandlerextendsResponseEntityExceptionHandler@... 查看详情
带有spring-boot的自定义sql中的Liquibase参数
】带有spring-boot的自定义sql中的Liquibase参数【英文标题】:Liquibaseparametersincustomsqlwithspring-boot【发布时间】:2019-04-1910:16:51【问题描述】:我在jdk11上有一个spring-boot应用程序,使用maven,具有以下liquibase依赖项:<dependency><... 查看详情
Spring Boot JPA中的自定义查询问题
】SpringBootJPA中的自定义查询问题【英文标题】:ProblemwithcustomQueryinSpringbootJPA【发布时间】:2020-07-0502:06:49【问题描述】:我正在尝试按范围计算记录数,但在运行服务时出现错误:Causedby:org.hibernate.hql.internal.ast.QuerySyntaxException:... 查看详情
Spring Boot - 实体中的自定义类字段
】SpringBoot-实体中的自定义类字段【英文标题】:SpringBoot-customclassfieldinentity【发布时间】:2017-11-2620:15:20【问题描述】:我有2个自定义类,OzBakim和GunlukEtkinlik。这些类不是实体。我需要在实体中使用这些类。但我得到一个错误... 查看详情
使用 Okta Spring Boot Starter 的自定义权限
】使用OktaSpringBootStarter的自定义权限【英文标题】:UsecustomauthoritieswithOktaSpringBootStarter【发布时间】:2020-10-1911:25:12【问题描述】:我正在使用OktaSpringBootStarter的版本1.4.0来验证传入的JWT令牌。通过使用Starter,身份验证和授权都... 查看详情
Spring boot - Application.properties 中的自定义变量
】Springboot-Application.properties中的自定义变量【英文标题】:Springboot-customvariablesinApplication.properties【发布时间】:2015-11-1014:05:59【问题描述】:我有一个使用restfulapi的springboot客户端。我可以使用application.properties中的任何密钥条... 查看详情
Spring Boot 异常处理数据库错误的自定义异常?
】SpringBoot异常处理数据库错误的自定义异常?【英文标题】:SpringBootExceptionHandlingcustomExceptionsforDatabaseErrors?【发布时间】:2022-01-1218:02:12【问题描述】:我为运行时可能发生的各种错误创建了多个自定义异常。为此,我使用了@... 查看详情
Spring Boot REST API 版本控制的自定义标头方法
】SpringBootRESTAPI版本控制的自定义标头方法【英文标题】:CustomHeaderApproachforSpringBootRESTAPIversioning【发布时间】:2020-04-2905:47:02【问题描述】:我希望实现使用自定义标头使用SpringBoot和Swagger对RESTAPI进行版本控制。我浏览了许多... 查看详情
无法在 Spring Boot Security 中登录到我的自定义登录页面
】无法在SpringBootSecurity中登录到我的自定义登录页面【英文标题】:Can\'tlogintomycustomloginpageinspringbootsecurity【发布时间】:2015-04-2509:29:19【问题描述】:我的问题是:当我尝试在我的自定义登录页面上登录时,它会再次将我重定... 查看详情
Spring Boot,MongoDB,Pageable,按对象中的自定义方法排序
】SpringBoot,MongoDB,Pageable,按对象中的自定义方法排序【英文标题】:SpringBoot,MongoDB,Pageable,sortbyacustommethodintheobject【发布时间】:2020-04-2214:27:46【问题描述】:比如说我有以下设置,这样的模型:publicclassPost@IdprivateStringid;privat... 查看详情
如何在 Spring Boot 中使用明确指定的编组器
】如何在SpringBoot中使用明确指定的编组器【英文标题】:HowtouseanexplicitlyspecifiedmarshallerinSpringBoot【发布时间】:2020-01-2202:55:57【问题描述】:我正在尝试创建一个能够生成XML输出的REST服务(我有一个包装在HATEOAS对象中的自定义... 查看详情
如何允许 Spring Boot 应用程序使用具有 Spring Cloud 依赖关系的自定义 jar
】如何允许SpringBoot应用程序使用具有SpringCloud依赖关系的自定义jar【英文标题】:Howtoallowspringbootapplicationstousecustomjarhavingspringclouddependency【发布时间】:2021-06-2520:09:30【问题描述】:我有许多SpringBoot微服务,并且我开发了一个... 查看详情
无法从 Spring Boot 应用程序中的自定义 yml 文件加载配置
】无法从SpringBoot应用程序中的自定义yml文件加载配置【英文标题】:Cannotloadconfigfromcustomymlfileinspringbootapplication【发布时间】:2017-11-1608:30:55【问题描述】:我正在从我的SpringBoot服务中的application.yml加载自定义配置。我已经通... 查看详情
Spring Boot - 如何通过实现 BeforeAllCallback 的自定义扩展类设置或覆盖 application.yml 中定义的属性?
】SpringBoot-如何通过实现BeforeAllCallback的自定义扩展类设置或覆盖application.yml中定义的属性?【英文标题】:SpringBoot-Howtosetoroverridepropertiesdefinedinapplication.ymlviaacustomextensionclassthatimplementsBeforeAllCallback?【发布时间】:2021-01-2909:10:49 查看详情
如何在 Spring Boot 中发送 400、401、405、403 和 500 错误的自定义响应?
】如何在SpringBoot中发送400、401、405、403和500错误的自定义响应?【英文标题】:Howtosendcustomresponsefor400,401,405,403and500errorsinspringboot?【发布时间】:2020-10-2009:25:21【问题描述】:我想在SpringBoot中针对400、401、405、403和500错误发送... 查看详情
Spring MVC(或 Spring Boot)。针对安全相关异常(例如 401 Unauthorized 或 403 Forbidden)的自定义 JSON 响应)
...oot)。针对安全相关异常(例如401Unauthorized或403Forbidden)的自定义JSON响应)【英文标题】:SpringMVC(orSpringBoot).CustomJSONresponseforsecurityrelatedexceptionslike401Unauthorizedor403Forbidden)【发布时间】:2018-05-2015:58:03【问题描述】:我正 查看详情
尝试在spring boot中将env变量读取到不在application.property中的自定义属性文件
】尝试在springboot中将env变量读取到不在application.property中的自定义属性文件【英文标题】:tryingtoreadenvvariablestocustompropertiesfilenotinapplication.propertyinspringboot【发布时间】:2021-01-0510:45:27【问题描述】:我正在尝试从custom.properties... 查看详情