spring-projects/spring-boot · error · ReportableException
Multiple types found with build '{this.build}' and format '{
Error message
Multiple types found with build '{this.build}' and format '{this.format}' use --type with a more specific value {types.keySet()} What it means
Thrown in detectType mode when filtering by --build and --format leaves more than one candidate ProjectType. Because the CLI cannot choose between them, it reports the conflicting keys and asks the caller to disambiguate with an explicit --type.
Source
Thrown at cli/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/ProjectGenerationRequest.java:389
return result;
}
else if (isDetectType()) {
Map<String, ProjectType> types = new HashMap<>(metadata.getProjectTypes());
if (this.build != null) {
filter(types, "build", this.build);
}
if (this.format != null) {
filter(types, "format", this.format);
}
if (types.size() == 1) {
return types.values().iterator().next();
}
else if (types.isEmpty()) {
throw new ReportableException("No type found with build '" + this.build + "' and format '" + this.format
+ "' check the service capabilities (--list)");
}
else {
throw new ReportableException("Multiple types found with build '" + this.build + "' and format '"
+ this.format + "' use --type with a more specific value " + types.keySet());
}
}
else {
ProjectType defaultType = metadata.getDefaultType();
if (defaultType == null) {
throw new ReportableException(("No project type is set and no default is defined. "
+ "Check the service capabilities (--list)"));
}
return defaultType;
}
}
/**
* Resolve the artifactId to use or {@code null} if it should not be customized.
* @return the artifactId
*/
protected @Nullable String resolveArtifactId() {View on GitHub (pinned to 5b2dbdbb8b)
Solutions
- Read the keys listed in the error message and pass the exact one via --type.
- Add another distinguishing flag (e.g. --packaging) only if the service tags types by it; otherwise --type is required.
- Run `spring init --list` to inspect the full tag set and pick the unambiguous type id.
Example fix
// before $ spring init --build maven --format project -> Multiple types found ... use --type ... [maven-project, maven-project-sticky] // after $ spring init --type maven-project myapp
Defensive patterns
Strategy: validation
Validate before calling
List<String> matches = metadata.getProjectTypes().entrySet().stream()
.filter(e -> Objects.equals(request.getBuild(), e.getValue().getTags().get("build")))
.filter(e -> Objects.equals(request.getFormat(), e.getValue().getTags().get("format")))
.map(Map.Entry::getKey).toList();
if (matches.size() > 1) {
throw new IllegalStateException("Ambiguous type; choose one: " + matches);
} Type guard
// Narrow to exactly one type before calling generateUrl
long n = metadata.getProjectTypes().values().stream()
.filter(t -> Objects.equals(request.getBuild(), t.getTags().get("build")))
.filter(t -> Objects.equals(request.getFormat(), t.getTags().get("format")))
.count();
boolean unambiguous = (n == 1); Try / catch
try { request.generateUrl(metadata); }
catch (ReportableException ex) {
if (ex.getMessage().startsWith("Multiple types found")) {
// parse keys, ask user to pick, then setType(chosen) and retry
} else throw ex;
} Prevention
- Pass --type whenever the build/format pair might match multiple variants.
- Review --list output for overlapping types before scripting.
- Treat ambiguity as a signal to pin the type explicitly.
When it happens
Trigger: Calling `spring init --build <b> --format <f>` where the service advertises multiple types sharing the same build and format tags (e.g. several variants differing only by other tags). The error message includes types.keySet() listing the ambiguous ids.
Common situations: A service that exposes overlapping type definitions (e.g. a default and a 'sticky' variant with identical build/format); a custom Initializr with non-unique tag combinations; partial flags that intentionally match a family of types.
Related errors
- No project type with id '${this.type}' - check the service c
- No type found with build '{this.build}' and format '{this.fo
- No project type is set and no default is defined. Check the
- Could not save the project, the server did not set a preferr
- {Directory|File} '{file.getName()}' already exists. Use --fo
AI-assisted analysis of spring-projects/spring-boot@5b2dbdbb8b (2026-08-04).
Data as JSON: /data/errors/9b36d9dd10f5bbb6.json.
Report an issue: GitHub.