Changes to kotlin class not recognized by Spring Boot? - eclipse

Changes are not reflected in the service response from http://localhost:8080/hi after:
Modifying the response string of SomeController in the code below
Spring Tool Suite automatically compiles the changes
Spring Boot DevTools automatically restarts the server
Request to http://localhost:8080/hi still gives the old response
Somehow they're getting cached, even after running ./gradlew build manually.
Totally different issues: I have Java 1.8 JRE and JDK installed into two directories under Program Files\Java. The project shows the JRE dependency and running build from STS Gradle Tasks window yields the JRE instead of the JDK, even though JAVA_HOME is properly set to the JDK, STS is configured to use the JDK by default (JRE unchecked), and the Spring Boot Project is configured to use the workspace settings (JDK). It seems to be picking up the JRE from the IDE runtime itself, instead of from the settings? I found a work-around by right-clicking the build task and selecting build -> Open Gradle Run Configuration -> Java Home and manually setting this to the same directory as the JDK. I also found a workaround for the project with right-click on project Properties -> Java Build Path -> Libraries, removing JRE System Library and adding the JDK (Add Library... -> JRE System Library -> Workspace default JRE (jdk1.8.0_144)). But, sometimes the project resets itself to the JRE somehow.
Gradle Distribution: Gradle wrapper from target build
Gradle Version: 4.5.1
Java Home: C:\Program Files\Java\jre1.8.0_171
Code
package com.example.demo
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RestController
#RestController
class SomeController {
#GetMapping("/hi")
fun hi(): String {
return "hey"
}
}
#SpringBootApplication
open class DemoApplication
fun main(args: Array<String>) {
runApplication<DemoApplication>(*args)
}
Configuration
Windows 10 Pro
Spring Tool Suite 3.9.4.RELEASE
JDK 1.8
Kotlin 1.2.41
Gradle Wrapper 4.5.1
Spring Boot + DevTools 2.0.3.RELEASE
Setup Steps
New workspace in STS with Gradle Buildship and Kotlin extensions
Add JDK 1.8 as default
Create project File -> New -> Spring Starter Project
Gradle (Buildship 2.x)
Java 8
Kotlin
Reactive Web
DevTools
Actuator
Right-click project Configure Kotlin -> Add Kotlin Nature
Start service Boot Dashboard -> local -> demo [devtools] [:8080]

Related

How does Eclipse apply an Expose Package configuration to a Maven build?

How does Eclipse propagate Java 11 "Expose Package..." to the Maven target?
I am exposing a Java 11 module to ALL-UNNAMED using Eclipse: Properties -> Java Build Path -> Module Dependencies -> Expose Package...
Nothing is added to pom.xml with this configuration yet the project builds successfully.
Using Eclipse 2020-06, m2e's maven 3.6.3, maven-compiler-plugin 3.8.1 (this is the only explicit override in pom.xml). The rest is the "EMBEDDED" maven.
When I look at the Maven console and effective pom I do not see any compilerArgs (--add-exports...) added. When I run mvn from the command line I do get compiler failure as expected.
How does m2e propagate --add-exports to javac without it being visible to help:effective-pom target or Maven console?
In Eclipse when I click "Show JPMS Options..." it does display "--add-exports ...", but nowhere in the m2e debug output does this appear.

Import source code: Could not install Gradle distribution

Gradle
michael#michael:~$ gradle -v
------------------------------------------------------------
Gradle 6.3
------------------------------------------------------------
Java
michael#michael:~$ java -version
java version "14.0.1" 2020-04-14
Spring Tool Suite 4 (an Eclipse derivative)
Version: 4.6.0.RELEASE
Buildship
Eclipse Plug-ins for Gradle 3.1.4.v20200326-1743 org.eclipse.buildship.feature.group Eclipse Buildship
I've downloaded a code samples for a book.
Then:
File -> Import -> Existing Gradle Project.
When I import, I override workspace settings:
1. Gradle version = 6.3
2. Gradle user home = /opt/gradle/gradle-6.3/bin
3. Java home = /usr/lib/jvm/jdk-14.0.1/bin
The same as described above:
The problem:
Description Resource Path Location Type
Could not install Gradle distribution from 'https://services.gradle.org/distributions/gradle-6.3-bin.zip'.
Could not create parent directory for lock file /opt/gradle/gradle-6.3/bin/wrapper/dists/gradle-6.3-bin/8tpu6egwsccjzp10c1jckl0rx/gradle-6.3-bin.zip.lck beginning-spring-5 line 0 Gradle Error Marker
The same as a picture:
Well, STS seems to be trying to install Gradle.
Could you help me understand what is going on and help cope with this.
If I do everything wrongly, please help me just import the source code.

Error running simple program in NetBeans 9.0

I'm trying to use NetBeans for a JDBC project. However, I'm getting runtime errors when I try to compile. I decided to try a "hello world" project and I couldn't get that to run also. I'm in NetBeans 9.0 with Java JDK 10.0.2.
Error Message:
Exception in thread "main" java.lang.RuntimeException:
at javaapplication2.JavaApplication2.main(JavaApplication2.java:1)
C:\Users\James\AppData\Local\NetBeans\Cache\dev\executor-snippets\run.xml:111: The following error occurred while executing this line:
C:\Users\James\AppData\Local\NetBeans\Cache\dev\executor-snippets\run.xml:68: Java returned: 1
BUILD FAILED (total time: 1 second)
xml debug:<call-java classname="#{classname}" classpath="#{classpath}" modulename="#{modulename}" modulepath="#{modulepath}">
package javaapplication2;
public class JavaApplication2 {
public static void main(String[] args) {
System.out.println("Hello");
}
}
It is very easy, your JDK version is not 100 % compatible; use version 8.2, which is the most stable for Arduino and others.
To change platforms without deleting the existing one, simply go to Tools / Java Platforms / click on the button add Platforms.
Download/install JDK major version number the same as NetBeans.
i.e. If You have NetBeans 9 version, but your JDK is version 10,So try use NetBeans 10 version... or download/install JDK 9 (the same as NetBeans).
Create new java platform for new jdk installation.
Open netbeans menubar->tools->Java Platforms->Add Platform Specify the folder that contains the Java platform as well as the sources and Javadoc needed for debugging.
Set new java platform to your project
Right click on project ->properties->Libraries->Java Platform->select the jdk version that same as NetBeans.
Select source format of your project
Right click on project ->properties->Sources->Sources/binary format->select the jdk version that same as NetBeans.
If it still give same error,Open the project properties, select the Build-Compiling, uncheck "Compile on save" and rerun the application. This will make sure all your source code becomes recompiled before running it.

TestNG [6.9.12] fails to load in Eclipse Mars [4.5.2] -- org.eclipse.core.runtime.CoreException

Expected behaviour
Should be possible to launch test via Run As -> TestNG ; also
should be able to add new Run configuration for TestNG
Actual behaviour
Plug-in org.testng.eclipse was unable to load class org.testng.eclipse.launch.TestNGTabGroup.
Exception:org.eclipse.core.runtime.CoreException: Plug-in org.testng.eclipse was unable to load class org.testng.eclipse.ui.TestNGQuickFixProcessor.
cannot be found by org.testng.eclipse_6.9.12.201607091356
Exception:org.eclipse.core.runtime.CoreException: Plug-in org.testng.eclipse was unable to load class org.testng.eclipse.ui.TestNGQuickFixProcessor.
Steps to reproduce
Install Eclipse Mars-2, 4.5.2
Install TestNG plugin from the Marketplace
Select an executable class
Attempt to "Run As TestNG"
Attempt to Run -> Run Configurations -> TestNG -> New
Running Configuration
Plugin Version: 6.9.12 [via eclipse marketplace]
(Optional) Operating System: Windows-10
An issue already exists on the project: https://github.com/cbeust/testng-eclipse/issues/272

I couldn't build Jhipster sample app

I'm trying to run Jhipster sample app in my Eclipse kepler . I've downloaded the project from here and I've imported it as existing maven project but it couldn't be build . I got this exception :
The type java.util.Optional cannot be resolved. It is indirectly referenced from required .class files AccountResource.java
and many "Undefined CSS file" errors
how can I run this project in my Eclipse ?
Normally you should create your application using the yeoman generator. Install yeoman and execute yo jhipster from your command line.
a)For the java exception basically you need to remove the old version of java from your build path and add support for java 8.
You need to follow these steps
1) Right-click on project » Properties » Java Build Path
2) Select Libraries tab
3) Find the JRE System Library and remove it
4) Click Add Library... button at right side » Add the JRE System Library(Workspace default JRE)
Do not forget to set the Java jdk compiler compliance level to 1.8 (Preference -> Java -> compiler )
b) The jhipster site mentions about the configuration settings(css,javascript and html etc)for eclipse to avoid errors in eclipe. https://jhipster.github.io/configuring_ide_eclipse.html