I'm getting the following errors when I'm trying to create a Jar file using SpringBoot.
[ERROR] HttpRequestTest.homePageReturnsVersionNumberCorrectly_thenSuccess:27 NoClassDefFound
[ERROR] ProjectRepositoryIntegrationTest.ifNewProjectSaved_thenSuccess:41 NoClassDefFound
[INFO]
[ERROR] Tests run: 3, Failures: 0, Errors: 2, Skipped: 0
Project Structure:
/project-management
/project-management/src/main/java
com.jrp.pma
/project-management/src/main/java/com/jrp/pma/ProjectManagementApplication.java
com.jrp.pma.controllers
/project-management/src/main/java/com/jrp/pma/controllers/EmployeeController.java
/project-management/src/main/java/com/jrp/pma/controllers/HomeController.java
/project-management/src/main/java/com/jrp/pma/controllers/ProjectController.java
com.jrp.pma.dao
com.jrp.pma.dto
com.jrp.pma.entities
com.jrp.pma.services
com.jrp.pma.springExample
com.jrp.utils
/project-management/src/main/resources
/project-management/src/test/java
com.jrp.pma
com.jrp.pma.controllers
com.jrp.pma.dao
/project-management/src/test/java/com/jrp/pma/dao/ProjectRepositoryIntegrationTest.java
/project-management/src/test/resources
/project-management/src/test/resources/application.properties
/project-management/src/test/resources/data.sql
/project-management/src/test/resources/drop.sql
/project-management/src/test/resources/schema.sql
/project-management/target/generated-sources/annotations
/project-management/target/generated-test-sources/test-annotations
/project-management/src
/project-management/src/main
/project-management/src/test
/project-management/target
/project-management/HELP.md
/project-management/mvnw
/project-management/mvnw.cmd
/project-management/pom.xml
Test:
package com.jrp.pma.dao;
import static org.junit.Assert.assertEquals;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
import org.springframework.boot.test.context.SpringBootTest;
//import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.jdbc.Sql;
import org.springframework.test.context.jdbc.Sql.ExecutionPhase;
import org.springframework.test.context.jdbc.SqlGroup;
import org.springframework.test.context.junit4.SpringRunner;
//import com.jrp.pma.dao.ProjectRepository;
import com.jrp.pma.entities.Project;
//@ContextConfiguration(classes=ProjectManagementApplication.class)
//@DataJpaTest
//@SqlGroup({@Sql(executionPhase = ExecutionPhase.BEFORE_TEST_METHOD, scripts= {"classpath:schema.sql", "classpath:data.sql"})})
@SpringBootTest
@RunWith(SpringRunner.class)
@SqlGroup({@Sql(executionPhase = ExecutionPhase.BEFORE_TEST_METHOD, scripts= {"classpath:schema.sql", "classpath:data.sql"}),
@Sql(executionPhase = ExecutionPhase.AFTER_TEST_METHOD, scripts= "classpath:drop.sql")})
public class ProjectRepositoryIntegrationTest {
@Autowired
ProjectRepository proRepo;
@Test
public void ifNewProjectSaved_thenSuccess() {;
Project newProject = new Project("New Test Project", "COMPLETE", "Test Description");
proRepo.save(newProject);
assertEquals(5, proRepo.findAll().size());
// assertEquals(1, proRepo.findAll().size());
}
}
POM.XML File
<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.4.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.jrp</groupId>
<artifactId>project-management</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>project-management</name>
<description>project management application</description>
<properties>
<java.version>15</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</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-services</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Console
2021-01-25 05:35:15.946 INFO 20352 --- [ main] c.j.p.d.ProjectRepositoryIntegrationTest : Starting ProjectRepositoryIntegrationTest using Java 15.0.1 on DESKTOP-2M3J99U with PID 20352 (started by alex in C:UsersalexDocumentsworkspace-spring-tool-suite-4-4.9.0.RELEASEproject-management)
2021-01-25 05:35:15.946 INFO 20352 --- [ main] c.j.p.d.ProjectRepositoryIntegrationTest : No active profile set, falling back to default profiles: default
2021-01-25 05:35:16.048 INFO 20352 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2021-01-25 05:35:16.061 INFO 20352 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 12 ms. Found 2 JPA repository interfaces.
2021-01-25 05:35:16.101 INFO 20352 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.ws.config.annotation.DelegatingWsConfiguration' of type [org.springframework.ws.config.annotation.DelegatingWsConfiguration$$EnhancerBySpringCGLIB$$64b58f15] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-01-25 05:35:16.106 INFO 20352 --- [ main] .w.s.a.s.AnnotationActionEndpointMapping : Supporting [WS-Addressing August 2004, WS-Addressing 1.0]
2021-01-25 05:35:16.141 INFO 20352 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-2 - Starting...
2021-01-25 05:35:16.143 INFO 20352 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-2 - Start completed.
2021-01-25 05:35:16.176 INFO 20352 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2021-01-25 05:35:16.181 INFO 20352 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
Hibernate: drop table if exists employee CASCADE
Hibernate: drop table if exists project CASCADE
Hibernate: drop table if exists project_employee CASCADE
Hibernate: drop sequence if exists project_seq
Hibernate: create sequence project_seq start with 1 increment by 1
Hibernate: create table employee (employee_id bigint not null, email varchar(255), first_name varchar(255), last_name varchar(255), primary key (employee_id))
Hibernate: create table project (project_id bigint not null, description varchar(255), name varchar(255), stage varchar(255), primary key (project_id))
Hibernate: create table project_employee (project_id bigint not null, employee_id bigint not null)
Hibernate: alter table project_employee add constraint FKn5yqs0xm3rmsg62n84ccyk4k0 foreign key (employee_id) references employee
Hibernate: alter table project_employee add constraint FK1907nkisp2dlsswuycpnakiv8 foreign key (project_id) references project
2021-01-25 05:35:16.213 INFO 20352 --- [ main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2021-01-25 05:35:16.213 INFO 20352 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2021-01-25 05:35:16.342 WARN 20352 --- [ main] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2021-01-25 05:35:16.382 INFO 20352 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2021-01-25 05:35:16.394 INFO 20352 --- [ main] o.s.b.a.h2.H2ConsoleAutoConfiguration : H2 console available at '/h2-console'. Database available at 'jdbc:h2:mem:f148eb08-7d43-4f50-9b33-270a6bd3468b'
2021-01-25 05:35:16.571 INFO 20352 --- [ main] c.j.p.d.ProjectRepositoryIntegrationTest : Started ProjectRepositoryIntegrationTest in 0.64 seconds (JVM running for 5.169)
Hibernate: call next value for project_seq
Hibernate: insert into project (description, name, stage, p
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…