Skip to content
Learn Netverks
-1

ErrorPageRegistrarBeanPostProcessor bean overriding error

asked 8 hours ago by @qa-fykkwfoa23my9nvkbxtp 0 rep · 56 views

java spring spring boot maven spring mvc

I created a MyApplication.java file following the tutorial under the URL linked below using maven.
https://docs.spring.io/spring-boot/tutorial/first-application/index.html

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@SpringBootApplication
public class MyApplication {

    @RequestMapping("/")
    String home() {
        return "Hello World!";
    }

    public static void main(String[] args) {
        SpringApplication.run(MyApplication.class, args);
    }

}

Then, I tried to run my application using this command: mvn --debug spring-boot:run.

But I ended up getting an exception about "A bean with that name has already been defined and overriding is disabled" implicating ErrorPageRegistrarBeanPostProcessor, which, I thought it was a dependency duplication, but after trying to check some duplicate, I didn't get nothing.

Maybe I could use spring.main.allow-bean-definition-overriding=true but I don't think is a good solution in the long term.

For more information, please let me know, thanks!

Logs:


  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/

 :: Spring Boot ::            (v4.1.0-RC1)

2026-05-31T18:00:44.482-06:00  INFO 27940 --- [           main] MyApplication                            : Starting MyApplication using Java 23.0.2 with PID 27940 (/home/ade/proyectos/practicas/spring/custom-greeting/untitled/target/classes started by ade in /home/ade/proyectos/practicas/spring/custom-greeting/untitled)
2026-05-31T18:00:44.490-06:00  INFO 27940 --- [           main] MyApplication                            : No active profile set, falling back to 1 default profile: "default"
2026-05-31T18:00:44.764-06:00  WARN 27940 --- [           main] ionWarningsApplicationContextInitializer : 

** WARNING ** : Your ApplicationContext is unlikely to start due to a @ComponentScan of the default package.


2026-05-31T18:00:47.115-06:00  WARN 27940 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.support.BeanDefinitionOverrideException: Invalid bean definition with name 'errorPageRegistrarBeanPostProcessor' defined in class path resource [org/springframework/boot/web/servlet/support/ErrorPageFilterConfiguration.class]: @Bean definition illegally overridden by existing bean definition: Root bean: class=org.springframework.boot.web.error.ErrorPageRegistrarBeanPostProcessor; scope=; abstract=false; lazyInit=null; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; fallback=false; factoryBeanName=null; factoryMethodName=null; initMethodNames=null; destroyMethodNames=null
2026-05-31T18:00:47.124-06:00  INFO 27940 --- [           main] .s.b.a.l.ConditionEvaluationReportLogger : 

Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
2026-05-31T18:00:47.155-06:00 ERROR 27940 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

The bean 'errorPageRegistrarBeanPostProcessor', defined in class path resource [org/springframework/boot/web/servlet/support/ErrorPageFilterConfiguration.class], could not be registered. A bean with that name has already been defined and overriding is disabled.

Action:

Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  10.344 s
[INFO] Finished at: 2026-05-31T18:00:47-06:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:4.1.0-RC1:run (default-cli) on project untitled: Process terminated with exit code: 1 -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:4.1.0-RC1:run (default-cli) on project untitled: Process terminated with exit code: 1
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:333)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
    at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
    at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
    at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:261)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:906)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:283)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:206)
    at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:103)
    at java.lang.reflect.Method.invoke (Method.java:580)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:255)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:201)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:361)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:314)
Caused by: org.apache.maven.plugin.MojoExecutionException: Process terminated with exit code: 1
    at org.springframework.boot.maven.JavaProcessExecutor.run (JavaProcessExecutor.java:75)
    at org.springframework.boot.maven.RunMojo.run (RunMojo.java:84)
    at org.springframework.boot.maven.AbstractRunMojo.run (AbstractRunMojo.java:263)
    at org.springframework.boot.maven.AbstractRunMojo.execute (AbstractRunMojo.java:226)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
    at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
    at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
    at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:261)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:906)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:283)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:206)
    at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:103)
    at java.lang.reflect.Method.invoke (Method.java:580)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:255)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:201)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:361)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:314)
[ERROR] 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[DEBUG] Shutting down adapter factory; available factories [file-lock, rwlock-local, semaphore-local, noop]; available name mappers [discriminating, file-gav, file-hgav, file-static, gav, static]
[DEBUG] Shutting down 'file-lock' factory
[DEBUG] Shutting down 'rwlock-local' factory
[DEBUG] Shutting down 'semaphore-local' factory
[DEBUG] Shutting down 'noop' factory



mvn dependency:tree

[INFO] 
[INFO] --- dependency:3.10.0:tree (default-cli) @ untitled ---
[INFO] org.example:untitled:jar:1.0-SNAPSHOT
[INFO] \- org.springframework.boot:spring-boot-starter-web:jar:4.1.0-RC1:compile
[INFO]    +- org.springframework.boot:spring-boot-starter-jackson:jar:4.1.0-RC1:compile
[INFO]    |  +- org.springframework.boot:spring-boot-starter:jar:4.1.0-RC1:compile
[INFO]    |  |  +- org.springframework.boot:spring-boot-starter-logging:jar:4.1.0-RC1:compile
[INFO]    |  |  |  +- ch.qos.logback:logback-classic:jar:1.5.32:compile
[INFO]    |  |  |  |  +- ch.qos.logback:logback-core:jar:1.5.32:compile
[INFO]    |  |  |  |  \- org.slf4j:slf4j-api:jar:2.0.17:compile
[INFO]    |  |  |  +- org.apache.logging.log4j:log4j-to-slf4j:jar:2.25.4:compile
[INFO]    |  |  |  |  \- org.apache.logging.log4j:log4j-api:jar:2.25.4:compile
[INFO]    |  |  |  \- org.slf4j:jul-to-slf4j:jar:2.0.17:compile
[INFO]    |  |  +- org.springframework.boot:spring-boot-autoconfigure:jar:4.1.0-RC1:compile
[INFO]    |  |  +- jakarta.annotation:jakarta.annotation-api:jar:3.0.0:compile
[INFO]    |  |  \- org.yaml:snakeyaml:jar:2.6:compile
[INFO]    |  \- org.springframework.boot:spring-boot-jackson:jar:4.1.0-RC1:compile
[INFO]    |     \- tools.jackson.core:jackson-databind:jar:3.1.2:compile
[INFO]    |        +- com.fasterxml.jackson.core:jackson-annotations:jar:2.21:compile
[INFO]    |        \- tools.jackson.core:jackson-core:jar:3.1.2:compile
[INFO]    +- org.springframework.boot:spring-boot-starter-tomcat:jar:4.1.0-RC1:compile
[INFO]    |  +- org.springframework.boot:spring-boot-starter-tomcat-runtime:jar:4.1.0-RC1:compile
[INFO]    |  |  +- org.springframework.boot:spring-boot-web-server:jar:4.1.0-RC1:compile
[INFO]    |  |  +- org.apache.tomcat.embed:tomcat-embed-core:jar:11.0.21:compile
[INFO]    |  |  +- org.apache.tomcat.embed:tomcat-embed-el:jar:11.0.21:compile
[INFO]    |  |  \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:11.0.21:compile
[INFO]    |  \- org.springframework.boot:spring-boot-tomcat:jar:4.1.0-RC1:compile
[INFO]    +- org.springframework.boot:spring-boot-http-converter:jar:4.1.0-RC1:compile
[INFO]    |  +- org.springframework.boot:spring-boot:jar:4.1.0-RC1:compile
[INFO]    |  |  +- org.springframework:spring-core:jar:7.0.7:compile
[INFO]    |  |  |  +- commons-logging:commons-logging:jar:1.3.6:compile
[INFO]    |  |  |  \- org.jspecify:jspecify:jar:1.0.0:compile
[INFO]    |  |  \- org.springframework:spring-context:jar:7.0.7:compile
[INFO]    |  \- org.springframework:spring-web:jar:7.0.7:compile
[INFO]    |     +- org.springframework:spring-beans:jar:7.0.7:compile
[INFO]    |     \- io.micrometer:micrometer-observation:jar:1.17.0-RC1:compile
[INFO]    |        \- io.micrometer:micrometer-commons:jar:1.17.0-RC1:compile
[INFO]    \- org.springframework.boot:spring-boot-webmvc:jar:4.1.0-RC1:compile
[INFO]       +- org.springframework.boot:spring-boot-servlet:jar:4.1.0-RC1:compile
[INFO]       \- org.springframework:spring-webmvc:jar:7.0.7:compile
[INFO]          +- org.springframework:spring-aop:jar:7.0.7:compile
[INFO]          \- org.springframework:spring-expression:jar:7.0.7:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS

mvn dependency:analyze-duplicate



[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------------< org.example:untitled >------------------------
[INFO] Building untitled 1.0-SNAPSHOT
[INFO]   from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- dependency:3.10.0:analyze-duplicate (default-cli) @ untitled ---
[INFO] No duplicate dependencies found in <dependencies/> or in <dependencyManagement/>
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  3.285 s
[INFO] Finished at: 2026-05-31T18:10:59-06:00
[INFO] ------------------------------------------------------------------------

pom.xml

<?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">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.example</groupId>
    <artifactId>untitled</artifactId>
    <version>1.0-SNAPSHOT</version>



    <!-- Inherit defaults from Spring Boot -->
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>4.1.0-RC1</version>
    </parent>

    <properties>
        <maven.compiler.source>23</maven.compiler.source>
        <maven.compiler.target>23</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>


    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    </dependencies>

</project>

Comments on this question (0)

Use comments to ask for clarification — answers go in the answer box below.

Log in to comment on this question.

1

In your code, MyApplication class has 2 annotation, "@RestController" and "@SpringBootApplication".

Both of these annotation use "@Component" in themself so when Spring boot tries to load the context load this beans twice.

One solution is have 2 separate class, one for Controller and another one for MyApplication.

Jordan Brooks · 0 rep · 8 hours ago

Your answer