I want to access DB using JPA in Spring.
An error will occur if this is described in pom.xml in the project.
Finally, I want to run the project with Maven install and send it to BUILD SUCCESS and console.

Error message

JPA settings cannot be made in pom.xml in the project.

Error message

[INFO] Results:
[ERROR] Errors:
[ERROR] ShopApplicationTests.contextLoads »IllegalState Failed to load ApplicationCon ...
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0
[INFO] ----------------------------------------------- -------------------------
[INFO] ----------------------------------------------- -------------------------
[INFO] Total time: 9.525 s
[INFO] Finished at: 2019-11-29T15: 13: 49 + 09: 00
[INFO] ----------------------------------------------- -------------------------
[WARNING] The requested profile "pom.xml" could not be activated because it does not exist.
[ERROR] Failed to execute goal org.apache.maven.plugins: maven-surefire-plugin: 2.22.2: test (default-test) on project shop: There are test failures.
[ERROR] Please refer to C: \ Program Files \ pleiades \ workspace \ shop \ target \ surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date] .dump, [date] -jvmRun [N] .dump and [date] .dumpstream.
[ERROR]->[Help 1]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

Applicable source code
<? 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">
        <relativePath /><!-lookup parent from repository->
    <description>Demo project for Spring Boot</description>
        </dependency><!-Settings for using JPA (this causes an error)->

        <!-Settings to use JDBC (object7.jar build path setting)->
            <systemPath>${basedir} /src/main/resources/lib/ojdbc7.jar</systemPath>

-If i comment out the corresponding source code, it has become BUILD SUCCESS, so we know that JPA settings are not made
-Add JPA from adding dependencies instead of writing code directly in xml
・ The library (?) Javax.persistence.XX that gives an error if JPA is not set in the Java class was used after writing the corresponding source code, but an error occurs when trying to execute it in the SpringBoot application

Supplemental information (FW/tool version etc.)

Spring (STS) 3.9.10
Java jdk13.0.1
DB Oracle Database 11g Express Edition
Template engine Thymleaf2.2.1
Build tool Maven
Servlet container Tomcat9

Beginning Spring learning.
I'm writing the code exactly as I did in the textbook,
It did n’t work.

  • Answer # 1

    Ifspring-boot-starter-data-jpais added to the dependency, the default is not set in the application configuration file (application.properties or application.yml) I think the test class created in fails.

    In this case, the following three points can be considered as countermeasures.
    Anything is fine, but the simplest is 1) or 2), and 3) is essential if you are writing code that will eventually connect to the database.

    1) Delete or disable the test class created by default.

    The test class created by default doesn't make much sense, so you can delete or disable it.

    Example) Delete

    DeleteShopApplicationTests.javawhere the error occurred.

    Example: Disable

    EditShopApplicationTests.javawhere the error occurred as follows.

    class ShopApplicationTests {
    // ... omitted ...
    2) Specify the skip option so that the test is not executed at build time.

    If you don't want to modify the test code, you can skip it at build time.

    Example) From Eclipse

    Open the Maven build execution configuration screen and check "Skip test" surrounded by a border

    Example) From the command line
    >mvn clean package -DskipTests = true
    3) Set the data source in the application setting file.

    Describe at least the necessary data source settings. After this setting, it is necessary to be able to connect to the database at the time of build.

    # JDBC URL of the database.
    spring.datasource.url =
    # Login username of the database.
    spring.datasource.username =
    # Login password of the database.
    spring.datasource.password =