question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

run spring boot with kscript

See original GitHub issue

I tried running

#!/usr/bin/env kscript

@file:DependsOn("org.springframework.boot:spring-boot-starter:2.0.4.RELEASE")

package my.package

import DependsOn
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.SpringApplication

@SpringBootApplication
class DummyApp

SpringApplication.run(DummyApp::class.java, *args)

it starts but fails with

ERROR org.springframework.boot.SpringApplication - Application run failed
java.lang.IllegalArgumentException: No auto configuration classes found in META-INF/spring.factories. If you are using a custom packaging, make sure that file is correct.
	at org.springframework.util.Assert.notEmpty(Assert.java:450)

A comparable groovy/@Grab script with the same setup works, so I wonder if this is something that can/will never work with kscript due to design or is just a missing feature that can be achieved … somehow

I know that running complex spring boot apps with kscript seems to be out of scope, but I have quite a experimental microservices that require minimal coding and would benefit from a scripting approach …

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
holgerbrandlcommented, Sep 10, 2018

I actually love the use-case.

It’s not working for me either. It’s because we don’t use spring’s custom packaging method.

The problem seems to center around the missing META-INF/spring.factories. However, even if I patch the jar created by kscript internally to include the file, it fails with the same error. So to progress here, we’d need to find a way to provide META-INF/spring.factories via classpath. It seems partially documented under https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-developing-auto-configuration.html#boot-features-developing-auto-configuration In particular is says

Auto-configuration classes can be bundled in external jars and still be picked-up by Spring Boot.

So if we could find a way to run a spring-app without their deployment-scheme by providing an extra-jar that adds the missing META-INF/spring.factories the classpath, we could configure kscript to run it accordingly.

0reactions
holgerbrandlcommented, Sep 11, 2018

I’m not so sure. Whenever a custom build-file is required (e.g. doing something like apply plugin: 'org.springframework.boot') than we will struggle doing this in kscript, since we can not (and do not really want to) mess with the build beyond classpath and compiler settings.

I personally find it an odd design choice by the spring people to force users to use a custom build-plugin.

Read more comments on GitHub >

github_iconTop Results From Across the Web

62. Installing Spring Boot Applications
In addition to running Spring Boot applications by using java -jar , it is also possible to make fully executable applications for Unix...
Read more >
Scripting in Kotlin with kscript - Fredrick Biering
The project was an app built with Kotlin and Spring Boot. ... want to do is to put a piece of code into...
Read more >
Issues · kscripting/kscript - GitHub
Contribute to kscripting/kscript development by creating an account on GitHub. ... kscripting / kscript Public ... run spring boot with kscript help wanted....
Read more >
Starting Spring boot applications from script - Stack Overflow
Using normal spring mvn commands, I can start a spring boot application from command line and terminate it with Control+c.
Read more >
Available SDKs - SDKMAN! the Software Development Kit ...
BTrace can be used to dynamically trace a running Java program (similar to ... Spring Boot takes an opinionated view of building production-ready...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found