Micronaut

How to use entitymanager with Micronaut?

落爺英雄遲暮 提交于 2020-02-06 07:38:42
问题 I'm new in Micronaut framework and I'm trying to use entitymanager to create my repository. I created my repository like this public interface EmployeeRepository { Employee save(@NotNull Employee employee); Employee update(@NotNull Employee employee); List<Employee> findAll(); Optional<Employee> findById(@NotNull Long id); } and I used this class to implement the interface and to inject entitymanager @Singleton public class EmployeeRepositoryImpl implements EmployeeRepository{

Get micronaut to use my instance of `JacksonConfiguration`

最后都变了- 提交于 2020-01-16 17:58:50
问题 I'm trying to get micronaut (1.2.6) to use my code to instantiate a JacksonConfiguration instead of the default mechanism. I have this: @Factory public class MyFactory { @Singleton public JacksonConfiguration jacksonConfiguration() { JacksonConfiguration cfg = new JacksonConfiguration(); System.out.println("jacksonConfiguration() - hashcode is " + System.identityHashCode(cfg)); return cfg; } @Factory public static class MyObjectMapperFactory extends ObjectMapperFactory { @Override @Singleton

Micronaut - shadow fat-jar plugin not working with corporate repo

房东的猫 提交于 2020-01-16 09:07:09
问题 I am using Micronaut framework for a project and Micronaut CLI generates project with com.github.johnrengelman.shadow gradle plugin which works fine when I run the jar using- $ java -Dmicronaut.environments=E1 -jar build/appBundle/app.jar build.gradle - plugins { id "com.github.johnrengelman.shadow" version "5.0.0" } ... shadowJar { mergeServiceFiles() } The issue is that com.github.johnrengelman.shadow plugin is not working with Jenkins for some reason and I am suspecting that it's not

Interoperability between Injections in Picocli commands and micronaut

元气小坏坏 提交于 2020-01-16 04:18:11
问题 Defining an @Singleton bean in Micronaut does not @Inject the same instance into Picocli commands. Micronaut offers an integration with Picocli. What is essential done, it seems, is that from the Picocli command, one can start an EmbeddedServer of Micronaut (maybe the problem is already here that Micronaut is started only really started from within Picocli?). When I define a class as singleton via @Singleton, and @Inject it both in a Rest-endpoint of Micronaut and the Picocli command, it

error: Unexpected error: Illegal name .$HelloControllerDefinition

纵然是瞬间 提交于 2020-01-06 13:58:29
问题 I have followed the Getting Started. First start of Application was Ok. Then I added a Controller as described (HelloController.java in src/main/java/helloworld. When I restart the server, I get the following error: c:\dev\micronaut\helloworld>gradlew run Task :compileJava FAILED Note: Creating bean classes for 1 type elements error: Unexpected error: Illegal name .$HelloControllerDefinition 1 error I am under Windows 10 with jdk 1.8_171 回答1: As Graeme Rocher mentioned, the class is missing

Can I use Apache Camel with Micronaut?

你离开我真会死。 提交于 2020-01-05 10:33:28
问题 We have been evaluating the Micronaut framework and are looking to use the Apache Camel library. I do not see a specific integration with Apache Camel. The Apache Camel library does support a set of annotations. Questions Can we use Apache Camel with Micronaut? If we attempt to use Apache Camel annotations, will it work but revert to using the Java annotation api, i.e. work but not be optimized for Micronaut? 回答1: Can we use Apache Camel with Micronaut? Yes. If we attempt to use Apache Camel

Is there an equivalent for Springs Resource in Micronaut?

时光怂恿深爱的人放手 提交于 2020-01-04 05:42:29
问题 I am migrating a tiny Spring Boot application to Micronaut 1.0.1 and I was wondering if there is an equivalent for org.springframework.core.io.Resource and their implementation such as ClasspathResource ? In Spring Boot I inject a resource into a service using its constructor. @Service public class MyService() { private final Resource resource; public MyService(Resource resource) { this.resource = resource; } } How can I do this in Micronaut? @Singleton public class MyService() { private

Micronaut JSON post strip the Quotes

浪子不回头ぞ 提交于 2019-12-25 18:37:37
问题 In Micronaut Controller parsing the post request using JSON object. I expect it to not include quotes, but it quotes in the database insert. Posting like this: curl -X POST --header "Content-Type: application/json" -d '{"bookid":3,"name":"C++"}' http://localhost:8880/book/save Saving like this: String bookid=JSON?.bookid String name=JSON?.name def b =bookService.save(bookid,name in database It stores like this: +--------+-------+ | bookid | name | +--------+-------+ | 3 | "C++" | +--------+--

Micronaut test conditional beans

﹥>﹥吖頭↗ 提交于 2019-12-24 10:47:29
问题 I'm working on and micronaut application, and I want to test a production bean. I have a bean that is conditional using @Requires(env="production" and another that loads when @Requires(notEnv="production") that is a simple mock of production. Is there a way in micronaut to mock enviroment so the production bean is created so that I can test it? 来源: https://stackoverflow.com/questions/56936903/micronaut-test-conditional-beans

Micronaut configure logger appenders based of the enviroment

为君一笑 提交于 2019-12-24 01:06:33
问题 I would like to configure logging appender based on the environment , for example while running in production I would like to configure an appender that would send log to elasticsearch but while on test or development mode this appender would not be enabled. 回答1: To put the correct answer here from the above comment. According to this link, you can just add a logback-production.xml , where production is the name of your profile. 回答2: As far I understand, Micronaut doesn't have similar thing