我正在使用spring boot,我决定只是为了把我的项目分成模块。我有4个模块,网络,服务,存储库,领域。除了JSP外,其他工作都很好,spring找不到这些页面。但当我没有把我的项目分成模块时,它就起作用了。我没有改变配置。
这是我的web模块结构
Runner位于web模块中,如下所示:
@SpringBootApplication(scanBasePackages = "kz.epam.javalab.daimoncool")
public class WebApplication {
public static void main(String[] args) {
SpringApplication.run(WebApplication.class, args);
}
}
spring.mvc.throw-exception-if-no-handler-found=true
spring.resources.add-mappings=false
spring.mvc.view.prefix:/WEB-INF/jsp/
spring.mvc.view.suffix:.jsp
spring.http.encoding.charset=UTF-8
spring.http.encoding.enabled=true
spring.http.encoding.force=true
spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver
spring.datasource.url=jdbc:oracle:thin:@localhost:1521:orcl
spring.datasource.username=
spring.datasource.password=
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.Oracle10gDialect
spring.jpa.properties.hibernate.physical_naming_strategy=com.vladmihalcea.hibernate.type.util.CamelCaseToSnakeCaseNamingStrategy
spring.mail.host=smtp.gmail.com
spring.mail.port=587
spring.mail.username=
spring.mail.password=
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.properties.mail.smtp.ssl.trust=smtp.gmail.com
<?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>kz.epam.javalab.daimoncool</groupId>
<artifactId>newsmanagementparent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>newsmanagementparent</name>
<packaging>pom</packaging>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<modules>
<module>repository</module>
<module>service</module>
<module>web</module>
<module>domain</module>
</modules>
<properties>
<java.version>1.8</java.version>
<module-version>0.0.1-SNAPSHOT</module-version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.20</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.5</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.25</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.spockframework</groupId>
<artifactId>spock-core</artifactId>
<version>1.1-groovy-2.4</version>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>kz.epam.javalab.daimoncool</groupId>
<artifactId>web</artifactId>
<version>${module-version}</version>
</dependency>
<dependency>
<groupId>kz.epam.javalab.daimoncool</groupId>
<artifactId>service</artifactId>
<version>${module-version}</version>
</dependency>
<dependency>
<groupId>kz.epam.javalab.daimoncool</groupId>
<artifactId>domain</artifactId>
<version>${module-version}</version>
</dependency>
<dependency>
<groupId>kz.epam.javalab.daimoncool</groupId>
<artifactId>repository</artifactId>
<version>${module-version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
<?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>kz.epam.javalab.daimoncool</groupId>
<artifactId>web</artifactId>
<packaging>war</packaging>
<parent>
<groupId>kz.epam.javalab.daimoncool</groupId>
<artifactId>newsmanagementparent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>kz.epam.javalab.daimoncool</groupId>
<artifactId>domain</artifactId>
</dependency>
<dependency>
<groupId>kz.epam.javalab.daimoncool</groupId>
<artifactId>service</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</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-security</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<!-- Need this to compile JSP -->
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
</dependency>
<!-- Need this to compile JSP -->
<dependency>
<groupId>org.eclipse.jdt.core.compiler</groupId>
<artifactId>ecj</artifactId>
<version>4.6.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
此外,Intellij想法还告诉我,index.jsp没有视图解析器,尽管我显式地添加了视图解析器bean
以下是项目的github链接:https://github.com/daimoncool/newsmanagementmultimodules
我发现问题了。我需要更改intellij IDEA中的工作目录。Spring boot runner获取根路径,然后查找jsp(在我的例子中是父项目)。但是我的runner在web模块中,所以我需要spring boot runner将根路径更改为web模块(通过更改工作目录),而不是父路径。
我似乎无法让Maven在多模块项目中找到兄弟姐妹的模块。 我已经在所有模块中运行了。 下面是MagnicCompCommon 下面是Model
我有一个基本的SpringBoot应用程序。使用Spring初始值设定项、嵌入式Tomcat、Thymeleaf模板引擎,并将包作为可执行的JAR文件。是一个带有Spring Boot的多模块项目,该项目将有3个模块。这里是父模块pom。xml 这里是模块核心 这里是模块web: 从父根目录,我使用以下方法生成所有模块: 但问题是tdk-web-0.0.2-SNAPSHOT。jar不包含tdk-c
父项目为demo-mybatis子模块为mybatis-dao、demo-service。demo-mybatis pom.xml如下: 4.0.0 pom mybatis-DAO Demo-service Demo-mybatis-app org.springframework.Boot spring-boot-starter-parent 2.3.2.release com.example D
我尝试将其添加到该模块中的中,如下所示: 但我还是得到了同样的错误。我甚至尝试将其添加到中 并且仍然得到相同的结果。 4.4级
我有一个带有myapp-core和myapp-web模块的myapp父pom类型maven项目。myapp-core模块作为依赖项添加到MyApp-Web。 myapp-core模块中的所有类都位于根包com.myapp.core中,而myapp-web模块中的所有类都位于根包com.myapp.web中 主要的application.java也在com.myapp.web包中。由于我的核心模块根
我使用的是Maven 3.0.3、JUnit 4.8.1和Java1.6。我在JUnit测试文件中有这个... 未拾取“test.properties”(输入流对象为空)。我的项目结构如下: parent+---pom.xml +----war模块 +------pom.xml +------src/test/java/junit文件 +------src/test/resources/test.