spring.erlang.node.name=my-node-name
spring.erlang.node.cookie=my-cookie
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-erlang</artifactId>
</dependency>
erlang
-module(my_module).
-export([add/2]).
add(X, Y) ->
java:add(X, Y).
package com.example;
public class Calculator {
public int add(int a, int b) {
return a + b;
}
}
package com.example;
import org.springframework.context.annotation.Configuration;
import org.springframework.erlang.core.ErlangTemplate;
import org.springframework.erlang.support.converter.DefaultErlangConverter;
@Configuration
public class ErlangConfig {
@Bean
public ErlangTemplate erlangTemplate() {
ErlangTemplate erlangTemplate = new ErlangTemplate();
erlangTemplate.setErlangConverter(new DefaultErlangConverter());
return erlangTemplate;
}
}
package com.example;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.erlang.core.ErlangTemplate;
import static org.junit.jupiter.api.Assertions.assertEquals;
@SpringBootTest
public class IntegrationTest {
@Autowired
private ErlangTemplate erlangTemplate;
@Test
public void testErlangIntegration() {
int result = erlangTemplate.executeScript("my_module:add", 2, 3, Integer.class);
assertEquals(5, result);
}
}