0

I'm not much of a Spring guru and was wondering if someone can help me.

I'm going through a Spring Security example found here: https://github.com/FutureProcessing/spring-boot-security-example

I have successfully loaded the tomcat server by running the Application.java file. I did that by Right-Clicking on Application.java in Intellij and then 'Run Application.main()'.

It had given me an error as Spring Boot was not picking up the application.properties file so I had to include an xml config file which is display below and this fixed it:

<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd">

<context:property-placeholder location="classpath:application.properties"/>

</beans>

Since the project does not contain a front end for testing purposes, I'm trying to run the SecurityTest.java for this project on github that shows how Spring Security works. When I run SecurityTest.java, I got the following exceptions:

Testing started at 06:55 PM ...
06:55:56 PM: Executing external tasks 'cleanTest test --tests com.futureprocessing.integration.SecurityTest'...
:cleanTest UP-TO-DATE
:compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
> invalid source release: 1.8
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 0.287 secs
invalid source release: 1.8

I then followed the advice of this stackoverflow post: Error:java: invalid source release: 8 in Intellij. What does it mean? and did all 4 steps and the test still doesn't run.

I'm not sure what I'm doing wrong. I'm running the original code as per github and I only included the xml config file which I have pasted above.

When I run the SecurityTest.java, it also gives me a message that says 'Empty test suite' which I'm unsure about.

Community
  • 1
  • 1
Simon
  • 19,658
  • 27
  • 149
  • 217
  • try 1. File->Invalidate caches and restart. 2. Turn idea off, delete .yml file from root dir. Open project again. – hi_my_name_is Jul 29 '15 at 18:07
  • I tried this step now but it doesn't work. It keeps on giving me the same error but what I have noticed as well is that under the event log, there is a message that says 'Empty test suite'. – Simon Jul 29 '15 at 18:18

1 Answers1

0

In addition to changing the Java source properties in Intellij, you also have to change it in maven. Add the following lines to your pom.xml:

<parent>
   ... where you have the spring-boot-starter-parent defined
</parent>

<!-- ADD THESE LINES -->
<properties>
    <java.version>1.8</java.version>
</properties>

That should help.

David H
  • 1,461
  • 2
  • 17
  • 37
  • The github project is gradle based. The java version in gradle already has targetCompatibility = 1.8 sourceCompatibility = 1.8: https://github.com/FutureProcessing/spring-boot-security-example/blob/master/build.gradle I'm sure the java version picked up correctly as 1.8 as the application.java compiled perfectly. The server is running fine and only the test is not working. – Simon Jul 29 '15 at 18:15