当前位置: 首页 > 知识库问答 >
问题:

Spring-Boot Maven,缺少依赖项@RESTController

岳玉书
2023-03-14

我是Springboot和Maven领域的新手,想问一下我在这里做错了什么/为什么它不能这样工作。

我的绒球

<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.3.1.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>de.martinm</groupId>
    <artifactId>SimpleTest</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>SimpleTest</name>
    <description>Test project using Spring</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>

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

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.maven</groupId>
            <artifactId>maven-core</artifactId>
            <version>3.0</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

共有1个答案

郎羽
2023-03-14

@RESTController注释包含在spring-web-x.x.x.jar中,您需要在pom.xml文件中包含spring-boot-starter-web依赖项:

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

由yl

 类似资料:
  • 我试图在Tomcat服务器上部署一个基于spring的web应用程序,但我无法自动连接EntityManager。根本原因是错误。 我假设我有不正确的HibernateJAR作为依赖项。任何帮助都将不胜感激 我之前看到一篇帖子指出,问题在于包含了以下依赖项,但我不包括这一项: 以下是我的POM依赖项:

  • 我正在尝试学习spring boot,但有一个测试案例失败了。我有下面的pom文件,其中包含了< code > spring-boot-starter-test 依赖项。据我所知,它应该从测试库拉必要的库,包括Mockito,JUnit等。在我的测试用例文件中,尽管我在maven dependencies下看到了JUnit jar,但是导入并没有得到解析。您能指导我解决这个问题吗,这样我就可以成功

  • 我在构建我的应用程序时遇到此问题。有人知道怎么回事吗? React Hook useEffect缺少依赖项:“conectar”。包括它或删除依赖项数组react hooks/dep

  • 在我的反应/redux应用程序中,我使用调度来调用每次安装组件时从redux中的状态检索数据的操作。问题正在使用状态发生我的方式不工作 下面是我得到的错误: React Hook useEffect缺少依赖项:“dispatch”。包括它或删除依赖项数组。像“getInvoiceData”这样的外部作用域值不是有效的依赖项,因为对它们进行变异不会重新呈现组件react HOOK/DEP 这是我的密

  • 我想更新商店中的值只有一次在第一次打开时,页面首次使用反应钩子打开。为此,我做了第二个参数的使用效果'[]'空列表。没有什么可以阻止它工作,但是我从ESLint规则中得到了一个警告:React Hook用效果有一个缺失的依赖项:“ChangeCount”。要么包含它,要么删除依赖数组react-追踪器/穷举-deps。如何删除此警告?