【问题标题】:Java Spring Boot Project without pom.xml没有 pom.xml 的 Java Spring Boot 项目
【发布时间】:2021-03-02 15:09:13
【问题描述】:

我是 Spring Boot 项目的新手。最近,我被要求为 Spring Boot 项目添加新功能。我得到了项目的源代码。令人惊讶的是,项目结构中缺少 pom.xml。此外,缺少 lib 目录。未提供外部 .jar。

没有pom.xml怎么知道需要的版本和合适的jar文件?

我试图添加一些相关的 spring jar 文件,但不幸的是我无法运行 spring 应用程序。 这是错误消息:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.0.0.RELEASE)

Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.abc.abcXmlApiService.abcxmlapiserviceApplication]; nested exception is org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name 'emailValidator' for bean class [com.abc.web.validator.EmailValidator] conflicts with existing, non-compatible bean definition of same name and class [com.abc.admin.web.validator.EmailValidator]
    at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:181)
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:315)
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:232)
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:275)
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:95)
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:705)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:531)
    at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.refresh(ReactiveWebServerApplicationContext.java:61)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752)
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:388)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:327)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1246)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1234)
    at com.abc.abcXmlApiService.abcxmlapiserviceApplication.main(abcxmlapiserviceApplication.java:25)
Caused by: org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name 'emailValidator' for bean class [com.abc.web.validator.EmailValidator] conflicts with existing, non-compatible bean definition of same name and class [com.abc.admin.web.validator.EmailValidator]
    at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.checkCandidate(ClassPathBeanDefinitionScanner.java:348)
    at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:286)
    at org.springframework.context.annotation.ComponentScanAnnotationParser.parse(ComponentScanAnnotationParser.java:132)
    at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:287)
    at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:242)
    at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:199)
    at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:167)
    ... 13 more

【问题讨论】:

  • 该项目很可能使用 Gradle 而不是 Maven。有build.gradle 文件吗?
  • lib 目录丢失 ... lib 目录不是强制性的,也不是必需的。
  • 根本不应该有lib目录。如果没有 POM 或 build.gradle,您将无法在此项目上取得进展。如果没有 maven 或 gradle 的构建文件,你就完蛋了,需要和你的经理谈谈。
  • @Jeroen Steenbeeke 不存在任何 gradle 构建脚本 (build.gradle)。
  • build.xml (Ant) 或 ivy.xml (Apache Ivy) 怎么样?考虑到这是一个 Spring Boot 项目,这有点远,所以除了 Maven 或 Gradle 之外我不会期待任何东西

标签: java spring spring-boot maven gradle


【解决方案1】:

错误信息Caused by: org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name 'emailValidator' for bean class [com.abc.web.validator.EmailValidator] conflicts with existing, non-compatible bean definition of same name and class [com.abc.admin.web.validator.EmailValidator] 明确指出,emailValidator在您的项目中重复,如果有重复请核对名称。

【讨论】:

    猜你喜欢
    • 2019-12-03
    • 1970-01-01
    • 2021-07-08
    • 2018-11-09
    • 2018-11-30
    • 2019-07-13
    • 2019-12-25
    • 1970-01-01
    • 2014-05-31
    相关资源
    最近更新 更多