Last Updated
Viewed 17 Times

I recently started working on a new mini spring-boot project (I'm very new to this) for learning purposes. But I'm finding some problem in setting up the IntelliJ IDE. First I downloaded the zip folder from the spring initializr site, and then I tried to import the extracted folder in the IDE. But no subsequent dialogue boxes get displayed after I select 'Maven' from 'Import project from external model' dialogue box. IDE isn’t responding after that. I don't know how to proceed. No error prompts or anything is popping up. I have installed Maven separately and the version is 3.6.3.

C:\Users\User>mvn --version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: C:\Program Files\apache-maven-3.6.3-bin\apache-maven-3.6.3\bin\..
Java version: 1.8.0_231, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk1.8.0_231\jre
Default locale: en_IN, platform encoding: Cp1252
OS name: "windows 8.1", version: "6.3", arch: "amd64", family: "windows"

The java version is 1.8:

C:\Users\User>java -version
java version "1.8.0_231"
Java(TM) SE Runtime Environment (build 1.8.0_231-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.231-b11, mixed mode)

I've created Spring Boot based on Maven project as described in one of the official guides. I use IntelliJ. Now I can run project in one of two ways:

  1. Click on green arrow next to main method
  2. Type mvn spring-boot:run in the command line

What's the difference between these two? Which one should I prefer and why? What does IntelliJ use internally to build the project?

I have a spring boot multi-module project in IntelliJ, The problem is, when I run the project in IntelliJ, it builds and works as expected but when I try a maven package, I get this error:

The POM for ng.biosec:enrollment_ws:jar:0.0.1-SNAPSHOT is missing, no dependency information available and The POM for ng.biosec:abis_module:jar:0.0.1-SNAPSHOT is missing, no dependency information available

and then the process fails.

Here is my pom.xml for the the two modules and the parent: enrollment_ws.xml pom

<?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">

<parent>
        <artifactId>integron</artifactId>
        <groupId>ng.biosec</groupId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>enrollment_ws</artifactId>
    <packaging>jar</packaging>

    <dependencies>


    </dependencies>
</project>

This is the abis_module.xml pom file:

<?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">
    <parent>
        <artifactId>integron</artifactId>
        <groupId>ng.biosec</groupId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>abis_module</artifactId>
    <packaging>jar</packaging>



</project>

This is the cpm.xml pom file that depends on the modules that contain the pom files mentioned above:

<?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">
    <parent>
        <artifactId>integron</artifactId>
        <groupId>ng.biosec</groupId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>cpm</artifactId>
    <packaging>jar</packaging>

    <dependencies>
        <dependency>
            <groupId>ng.biosec</groupId>
            <artifactId>enrollment_ws</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>ng.biosec</groupId>
            <artifactId>abis_module</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.ws</groupId>
            <artifactId>spring-ws-core</artifactId>
        </dependency>
    </dependencies>


</project>

The cpm module contains the Spring boot application class. This is the Spring Application class:

@SpringBootApplication
@EnableScheduling
@EnableJpaRepositories(basePackages = {"integron"})
@ComponentScan(basePackages = {"integron"})
@EntityScan(basePackages = {"integron"})
public class BioConnectApplication {
    public static void main(String[] args) {
        SpringApplication.run(BioConnectApplication.class, args);
    }
}

Also, this is the parent pom file:

<?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>
    <modules>
        <module>enrollment_ws</module>
        <module>cpm</module>
        <module>verification</module>
        <module>abis_module</module>
    </modules>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.1.RELEASE</version>
        <relativePath/> <!-- lookup parent from integron.repository -->
    </parent>
    <groupId>ng.biosec</groupId>
    <artifactId>integron</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>pom</packaging>
    <name>integron</name>
    <description>Bio Connect Project</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>

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

            <!-- tag::wsdl[] -->
            <plugin>
                <groupId>org.jvnet.jaxb2.maven2</groupId>
                <artifactId>maven-jaxb2-plugin</artifactId>
                <version>0.13.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <schemaLanguage>WSDL</schemaLanguage>
                    <generatePackage>integron.client</generatePackage>

                    <schemas>
                        <schema>
                            <url>********?wsdl</url>
                        </schema>
                    </schemas>
                </configuration>
            </plugin>
            <!-- end::wsdl[] -->
        </plugins>
    </build>


    <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-web</artifactId>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>



</project>

Also: I replaced the link to the WSDL file for security reason, but the maven project also does not generate classes from the WSDL. Any help with that will be greatly appreciated.

I'm using IntelliJ IDEA 2016.2.5 and I've used Spring Initializr to setup a Spring Boot project. Everything works fine and I can run and test my project in the IDE.

Right now, when I want to build the jar file, I run the following command from command prompt:

$ mvn package

where my pom.xml is located and the jar file is created perfectly (with a caveat that I'm going to tell you about it later). The thing is, I'm looking for a way to do the same from within the IDE.

So far I've tried to create a new jar artifact in Project Structure window (Alt+Ctrl+Shift+s) and include the project's output while for the maven dependencies I use Extract into Output Root. This way, the artifact can be built and run but there are lots of error messages given out and some of the functionalities are not working.

Does anyone know how to build a jar file for Spring Boot project from within IntelliJ IDEA?

The reason why I need to build my jar file in IDE is that my project is composed of several maven projects and I've imported them all as modules into one project. When I run the main module in the IDE, IntelliJ IDEA is smart enough to consider the module as the dependencies for the main one. But when I use the command prompt mvn, this is not happening (which is totally understandable since maven only knows of main project and not the rest). If only I can build from within the IDE..

To clarify my situation better, I've got a "Main" project and a "Library" which of course Library is a dependency of Main. Since I don't have maven repository (and at this point, I'm not looking for one), the only way I know of to make it possible for the maven to compile my code is to name Library in Main's pom.xml like this:

<dependency>
    <groupId>org.example</groupId>
    <artifactId>library</artifactId>
    <version>1.0-SNAPSHOT</version>
    <scope>system</scope>
    <systemPath>${basedir}/lib/library-1.0-SNAPSHOT.jar</systemPath>
</dependency>

which as far as I know is highly discouraged. This is in the case that if I name the Library as an ordinary dependency:

<dependency>
    <groupId>org.example</groupId>
    <artifactId>library</artifactId>
    <version>1.0-SNAPSHOT</version>
</dependency>

since a neighboring module (Library) outputs the exact same artifact, IntelliJ IDEA is capable of matching the dependency with that module and compile the code. But in case of mvn, since there's no module involved, this can not be done and the dependency is not satisfied. In other words, I can only config my environment to work with mvn or IntelliJ IDEA, but not both!

Similar Question 6 (1 solutions) : Create Jar of maven spring boot project

Similar Question 8 (2 solutions) : Intellij Run Configuration Spring Boot vs Maven Issues

cc