Browse Source

Java SpringBoot running Scala component

Antoine DORIAN 2 years ago
parent
commit
d06c794fec

+ 32
- 0
pom.xml View File

@@ -25,6 +25,30 @@
25 25
     <build>
26 26
         <plugins>
27 27
             <plugin>
28
+                <groupId>org.apache.maven.plugins</groupId>
29
+                <artifactId>maven-compiler-plugin</artifactId>
30
+                <version>3.8.1</version>
31
+                <configuration>
32
+                    <source>18</source>
33
+                    <target>18</target>
34
+                </configuration>
35
+            </plugin>
36
+            <plugin>
37
+                <groupId>org.apache.maven.plugins</groupId>
38
+                <artifactId>maven-shade-plugin</artifactId>
39
+                <version>3.2.4</version>
40
+                <configuration>
41
+                </configuration>
42
+                <executions>
43
+                    <execution>
44
+                        <phase>package</phase>
45
+                        <goals>
46
+                            <goal>shade</goal>
47
+                        </goals>
48
+                    </execution>
49
+                </executions>
50
+            </plugin>
51
+            <plugin>
28 52
                 <groupId>net.alchim31.maven</groupId>
29 53
                 <artifactId>scala-maven-plugin</artifactId>
30 54
                 <version>3.1.3</version>
@@ -64,6 +88,14 @@
64 88
             <groupId>com.typesafe.akka</groupId>
65 89
             <artifactId>akka-stream_${scala.binary.version}</artifactId>
66 90
         </dependency>
91
+
92
+        <!-- alpakka -->
93
+        <dependency>
94
+            <groupId>com.lightbend.akka</groupId>
95
+            <artifactId>akka-stream-alpakka-file_2.13</artifactId>
96
+            <version>4.0.0</version>
97
+        </dependency>
98
+
67 99
         <!-- SpringBoot -->
68 100
         <dependency>
69 101
             <groupId>org.springframework.boot</groupId>

+ 13
- 0
src/main/java/com/mediahub/MediahubApplication.java View File

@@ -0,0 +1,13 @@
1
+package com.mediahub;
2
+
3
+import org.springframework.boot.SpringApplication;
4
+import org.springframework.boot.autoconfigure.SpringBootApplication;
5
+
6
+@SpringBootApplication
7
+public class MediahubApplication {
8
+
9
+    public static void main(String[] args) {
10
+        SpringApplication.run(MediahubApplication.class, args);
11
+    }
12
+
13
+}

+ 17
- 0
src/main/scala/com/mediahub/HelloWorld.scala View File

@@ -0,0 +1,17 @@
1
+package com.mediahub
2
+
3
+import org.springframework.stereotype.Component
4
+
5
+@Component
6
+class HelloWorld {
7
+  println("Hello from default constructor")
8
+  greet()
9
+
10
+
11
+
12
+  def greet() = {
13
+    val greeting = "Hello from SCALA!!!!"
14
+    println(greeting)
15
+  }
16
+
17
+}

+ 0
- 13
src/main/scala/com/mediahub/SpringBootIntegration.scala View File

@@ -1,13 +0,0 @@
1
-package com.mediahub
2
-
3
-import org.springframework.boot.{CommandLineRunner, SpringApplication}
4
-import org.springframework.boot.autoconfigure.SpringBootApplication
5
-
6
-@SpringBootApplication
7
-class SpringBootIntegration extends CommandLineRunner{
8
-  override def run(args: String*): Unit = println("\n\n\n *** Hello World \n\n\n")
9
-}
10
-
11
-object SpringBootIntegration extends App {
12
-  SpringApplication.run(classOf[SpringBootIntegration])
13
-}

Powered by TurnKey Linux.