2

I've spent the past two days attempted to get Spring Boot to work. However, I have been unable to get a brand new, clean project to run inside of IntelliJ Idea.

Here's what I'm doing:

  1. Open IntelliJ Idea
  2. Create a new project with Spring Initializr with the dependencies Security, Web, Rest Repositories, JPA, H2, and Actuator.
  3. Run the Java file called Application.java
  4. Get this output.
  5. (╯°□°)╯︵ ┻━┻

Here is my 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.aroid</groupId>
    <artifactId>restserver</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>

    <name>AroidRESTServer</name>
    <description>Aroid REST Server</description>

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

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <!-- Start what I added -->

        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-api</artifactId>
            <version>7.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
        </dependency>
        <dependency>
            <groupId>javax.el</groupId>
            <artifactId>javax.el-api</artifactId>
            <version>2.2.4</version>
        </dependency>


        <!-- End what I added -->

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</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-security</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</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</artifactId>
            <version>1.2.7.RELEASE</version>
        </dependency>
    </dependencies>

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


</project>

Note: I have a section in the dependencies where I label the things I added by hand. These are things that Spring Initializr did not automatically add (and should have), so I needed to add them manually to get the project to run.

I believe the issue has to do with my IntelliJ Idea setup, since running a new project in STS (Spring Tool Suite) runs fine.

Some other things I've tried and still getting the same result:

  • Using the web version of Spring Initializr.
  • Creating a new Spring Boot project without any libraries
  • Downloading sample projects and running them.
  • Adding dependencies that have this library manually via Maven.
  • Creating then project in STS and importing it into IntelliJ Idea.
  • Basically anything within the first ten pages of Google Search results for the issue.

Any help would be quite helpful.

Thanks, Nathan

Zoyt
  • 4,809
  • 6
  • 33
  • 45
  • Never used STS, but it seems weird that the Tomcat/EE dependencies are provided. AFAIK they should be provided when you deploy your app as a WAR to Tomcat. When you run it via Application main method, they should be compile. – Bohuslav Burghardt Nov 16 '15 at 08:59
  • 1
    I would like to help you, but i can't open your output, because my company blocks this URL. So please add the relevant output to your post. – dunni Nov 16 '15 at 09:38
  • And what makes you think, that Spring Initializr should add Java EE APIs? It's called Spring Initializr, not Java EE Initializr. – dunni Nov 16 '15 at 09:39
  • 1
    This has nothing to do with intellij -- the application starts fine, but fails loading your configuration because your dependencies are wrong. Please remove the intellij tag and fix your dependencies -- it even tells you in your stacktrace which one is wrong, it's pretty simple. – Software Engineer Nov 16 '15 at 15:28
  • @dunni SO doesn't seem to format it correctly and it exceeds the number of characters allowed. You can see the log [here](https://web.archive.org/web/20151116220316/http://pastebin.com/BqPHPwTG). – Zoyt Nov 16 '15 at 22:03
  • @dunni Also, I'm trying to use the JPA, and I know that `javaee-api` includes it, so for now, I'm including it as a shotgun approach to solving the issue. When I pinpoint the issue, I'll fix the dependencies. – Zoyt Nov 16 '15 at 22:05
  • @EngineerDollery Hmm, I'm not sure I see what you're looking at. If you could point it out and leave it in an answer below, that'd be great. I removed the `intellij-idea` tag; I previously believed it had to do with my IDE because it ran in STS but not IntelliJ. Thanks! – Zoyt Nov 16 '15 at 22:10
  • @BohuslavBurghardt Spring Boot prefers using an embedded container ("make jar, not war"), and the default is Tomcat. – chrylis -cautiouslyoptimistic- Nov 16 '15 at 23:21

0 Answers0