小编A.M*_*A.M的帖子

无法确定一对一关系的孩子/依赖方

我试图在包管理器控制台中使用“update-database”命令更新我的数据库,但我遇到了这种错误:

The child/dependent side could not be determined for the one-to-one 
relationship between 'Country.CapitalCity' and 'CapitalCity.Country'. To 
identify the child/dependent side of the relationship, configure the foreign 
key property. If these navigations should not be part of the same 
relationship configure them without specifying the inverse. See 
http://go.microsoft.com/fwlink/?LinkId=724062 for more details.
Run Code Online (Sandbox Code Playgroud)

我的模型类如下所示:

public class Country
{
    public int ID { get; set; }
    public string Name { get; set; }
    public long Population { get; set; }

    public int CapitalCityID …
Run Code Online (Sandbox Code Playgroud)

entity-framework entity-framework-core

22
推荐指数
1
解决办法
2万
查看次数

osweb.servlet.PageNotFound - 没有映射 GET /WEB-INF/views/welcome.jsp

请在否决票之前写下原因或搁置问题或其他...

我创建了简单的 spring-boot 应用程序,但由于某种原因无法映射视图,并且出现以下错误:

o.s.web.servlet.PageNotFound - No mapping for GET /WEB-INF/views/welcome.jsp
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

此语句后出现问题:

return "welcome";
Run Code Online (Sandbox Code Playgroud)

这是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>com.example</groupId>
    <artifactId>demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>demo</name>
    <description>Demo project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.1.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <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>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    </dependencies>

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


</project>
Run Code Online (Sandbox Code Playgroud)

我的文件夹结构如下所示:

在此处输入图片说明

这是WelcomeController …

java spring-boot

6
推荐指数
2
解决办法
8611
查看次数