Cannot resolve MVC view
enter image description here here is pom.xml:
4.0.0 org.springframework.boot spring-boot-starter-parent 2.7.5 com.test stock 0.0.1-SNAPSHOT stock stock <java.version>17</java.version> org.springframework.boot spring-boot-starter-data-jpa
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.14</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<!-- Lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.24</version>
<scope>provided</scope>
</dependency>
<!-- Validator -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
It gives this error, as I understand the problem is that Spring does not see the path to the HTML
CodePudding user response:
Ok, you need to check your ViewResolver (in spring boot you just have to add some properties and values to application.properties).
Example in application.properties:
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
Here, you can check how to configure in both ways, by properties or adding a bean programmatically, just in case you need to do some customization.
Cheers.
CodePudding user response:
Are you getting a runtime exception, or are you just concerned about the IntelliJ warning?
If it's the latter, you can configure where IntelliJ looks for these resources by going to File->Project Structure->Modules
(or right-click your project and select Open Module Settings
). On the left side, you should see Web
, select this and add the directory where your views are to the Web Resource Directories
.