0 Replies - 533 Views - Last Post: 28 May 2018 - 03:12 AM

#1 tekblade   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 77
  • Joined: 21-December 17

Solid way to run Spring Boot applications with Maven

Posted 28 May 2018 - 03:12 AM

Hi,
Do you have solid way to run mvn commands that runs Spring Boot applications. I am using maven 3.5.3. Closing application and then running for testing purposes after changes:
I used command in windows 10:
mvn package



my current 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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>authorizationSystem</groupId>
  <artifactId>auth</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>auth</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

 
  
  <dependencies>    
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
	
	<dependency>
    	<groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.1.0</version>
        <scope>provided</scope>
    </dependency> 	  	
  		<dependency>
    	<groupId>org.springframework</groupId>
    	<artifactId>spring-context</artifactId>
    	<version>3.0.2.RELEASE</version>
	</dependency>
  	
  	<dependency>
    	<groupId>org.springframework</groupId>
    	<artifactId>spring-webmvc</artifactId>
    	<version>5.0.6.RELEASE</version>
	</dependency>
    <dependency>
    	<groupId>org.springframework.boot</groupId>
    	<artifactId>spring-boot-starter-test</artifactId>
    	<version>2.0.2.RELEASE</version>
    	<scope>test</scope>
	</dependency>
  	
  	<dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
		<version>2.0.2.RELEASE</version>    
    </dependency>
    <dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-tomcat</artifactId>
			<version>2.0.2.RELEASE</version>
			<scope>provided</scope>
	</dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
    	<version>2.0.2.RELEASE</version>
    </dependency>
  	
  	<dependency>
    	<groupId>org.springframework.security</groupId>
    	<artifactId>spring-security-web</artifactId>
    	<version>5.0.5.RELEASE</version>
	</dependency>
  	<dependency>
		<groupId>org.springframework.security</groupId>
		<artifactId>spring-security-config</artifactId>
		<version>5.0.5.RELEASE</version>
	</dependency>
  </dependencies>
	
</project>



mvn clean install
mvn tomcat7:run // it doesn't run spring application


output looks:
C:\Users\lukas\workspace\auth>mvn spring-boot:run
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< authorizationSystem:auth >----------------------
[INFO] Building auth 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] >>> spring-boot-maven-plugin:2.0.2.RELEASE:run (default-cli) > test-compile @ auth >>>
[WARNING] The POM for org.springframework:spring-web:jar:5.0.6.RELEASE is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for org.apache.logging.log4j:log4j-to-slf4j:jar:2.10.0 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for com.fasterxml.jackson.core:jackson-databind:jar:2.9.5 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.9.5 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.9.5 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.9.5 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for org.springframework.boot:spring-boot-starter-tomcat:jar:2.0.2.RELEASE is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for org.hibernate.validator:hibernate-validator:jar:6.0.9.Final is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ auth ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ auth ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ auth ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\lukas\workspace\auth\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ auth ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] <<< spring-boot-maven-plugin:2.0.2.RELEASE:run (default-cli) < test-compile @ auth <<<
[INFO]
[INFO]
[INFO] --- spring-boot-maven-plugin:2.0.2.RELEASE:run (default-cli) @ auth ---
[WARNING]
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.springframework.boot.maven.AbstractRunMojo$LaunchRunner.run (AbstractRunMojo.java:496)
    at java.lang.Thread.run (Thread.java:748)
Caused by: java.lang.NoClassDefFoundError: org/springframework/core/env/ConfigurableEnvironment
    at authorizationSystem.auth.AuthApplication.main (AuthApplication.java:10)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.springframework.boot.maven.AbstractRunMojo$LaunchRunner.run (AbstractRunMojo.java:496)
    at java.lang.Thread.run (Thread.java:748)
Caused by: java.lang.ClassNotFoundException: org.springframework.core.env.ConfigurableEnvironment
    at java.net.URLClassLoader.findClass (URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass (ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass (ClassLoader.java:357)
    at authorizationSystem.auth.AuthApplication.main (AuthApplication.java:10)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.springframework.boot.maven.AbstractRunMojo$LaunchRunner.run (AbstractRunMojo.java:496)
    at java.lang.Thread.run (Thread.java:748)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.875 s
[INFO] Finished at: 2018-05-28T13:17:37+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.0.2.RELEASE:run (default-cli) on project auth: An exception occurred while running. null: InvocationTargetException: org/springframework/core/env/ConfigurableEnvironment: org.springframework.core.env.ConfigurableEnvironment -> [Help 1]
[ERROR]
[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]
[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/MojoExecutionException

C:\Users\lukas\workspace\auth> //it happens every time I thought it should be waiting in loop




EDIT:

Still the same error
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.4.2.RELEASE:run (default-cli) on project auth: An exception occurred while running. null: InvocationTargetException: org/springframework/core/env/Environment: org.springframework.core.env.Environment -> [Help 1]


This post has been edited by tekblade: 28 May 2018 - 09:13 AM


Is This A Good Question/Topic? 0
  • +

Page 1 of 1