spring-projects/spring-boot · error · ReportableException

No project type is set and no default is defined. Check the

Error message

No project type is set and no default is defined. Check the service capabilities (--list)

What it means

Thrown when no --type was set, detectType is not active, and the Initializr service metadata reports no default project type (InitializrServiceMetadata.getDefaultType() returns null). The CLI has no way to pick a type and aborts rather than send an untyped request.

Source

Thrown at cli/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/ProjectGenerationRequest.java:396

			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() {
		if (this.artifactId != null) {
			return this.artifactId;
		}
		if (this.output != null) {
			int i = this.output.lastIndexOf('.');
			return (i != -1) ? this.output.substring(0, i) : this.output;
		}

View on GitHub (pinned to 5b2dbdbb8b)

Solutions

  1. Run `spring init --list` against the same --target to confirm what (if anything) the service advertises.
  2. Always pass an explicit --type so generation does not depend on a server default.
  3. Verify --target points to a working Initializr (default https://start.spring.io) and that network/proxy isn't intercepting the metadata response.

Example fix

// before
$ spring init --target https://internal-start/ myapp
  -> No project type is set and no default is defined
// after
$ spring init --target https://internal-start/ --list   # inspect capabilities
$ spring init --target https://internal-start/ --type maven-project myapp
Defensive patterns

Strategy: validation

Validate before calling

InitializrServiceMetadata md = InitializrServiceMetadata.forService(request.getServiceUrl());
if (request.getType() == null && !request.isDetectType() && md.getDefaultType() == null) {
    throw new IllegalStateException(
        "Service " + request.getServiceUrl() + " has no default type; set --type explicitly.");
}

Type guard

boolean safeToGenerate = request.getType() != null
    || request.isDetectType()
    || metadata.getDefaultType() != null;

Try / catch

try { request.generateUrl(metadata); }
catch (ReportableException ex) {
    if (ex.getMessage().contains("no default is defined")) {
        // require user to pass --type or switch --target to a fuller service
    } else throw ex;
}

Prevention

When it happens

Trigger: Invoking `spring init` with neither --type nor (--build/--format with detectType) against a service whose metadata has no 'default' type entry. Typical of a minimal or misconfigured Initializr instance, or a service whose metadata payload was altered/filtered.

Common situations: Using a custom/private Initializr that didn't set a default type; service metadata partially unavailable due to a proxy returning an error page instead of JSON; pointing at the wrong URL so metadata parsing yields an empty type map.

Related errors


AI-assisted analysis of spring-projects/spring-boot@5b2dbdbb8b (2026-08-04). Data as JSON: /data/errors/a1837c97d93d2ccf.json. Report an issue: GitHub.