Spring

problem creating an executable jar with maven using spring 5 and hibernate 5 => BeanDefinitionParsingException

随声附和 提交于 2021-02-11 13:48:18
问题 Update: As there is only one answer for now I try to describe it better now. In short words, my test application runs fine in eclipse and when starting with mvn exec but building a running/working executable jar package does not work for this project. Now the longer description. I'm learning Java for about 8 month and use maven to setup build projects and Eclipse as IDE for writing and debugging. Currently I am trying to make some small database projects using Spring, Hibernate and for

java.lang.IllegalArgumentException: 'json' argument must be an instance of: [class java.lang.String, class [B

余生颓废 提交于 2021-02-11 13:43:19
问题 I am making a third party request in Hybris1811 framework using Spring Rest Template . But after getting response I am Getting below error: Could not properly initialize user sessionorg.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalArgumentException: 'json' argument must be an instance of: [class java.lang.String, class [B, class java.io.File, class java.net.URL, class java.io.InputStream, class java.io.Reader] , but gotten:

Can not load external script js file wtih spring

喜你入骨 提交于 2021-02-11 13:34:26
问题 Structure is: src -main --resources ---vue.html ---example.js vue.html is: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <!-- <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>--> <script src="./example.js"></script> <script> alert("I'm active"); </script> this is working for the alert : I'm active but 404 for http://localhost:8080/example.js but for, it gives error. SAme error. By the way, the endpoind is that: @GetMapping("/vue")

How to track login of users in a Java Spring Boot application

懵懂的女人 提交于 2021-02-11 13:19:18
问题 The application is already configured via Spring Session to log user sessions into a SQL database. Now I would like to log the user sessions into my own database table for purposes of tracking user login data. What are some possible ways to do so? 回答1: You can create a bean which implements ApplicationListener<> , for either AuthenticationSuccessEvent or InteractiveAuthenticationSuccessEvent events. See for further info: http://www.baeldung.com/spring-events https://docs.spring.io/spring-boot

这个404你能解决吗?

别来无恙 提交于 2021-02-11 13:17:13
点击上方蓝字关注 👆👆 今天在tomcat里部署运行了一个小工程,工程结构如下: 运行tomcat服务器后,访问index.html,发现报404: 但是后台接口是正常返回的: 去看webapps里工程目录下,index.html文件是有的,见鬼了,是哪儿出了问题? 然后看到控制台日志(或者tomcat_home/logs/catalina.log)报错如下: org.springframework.web.servlet.PageNotFound.noHandlerFound No mapping fo und for HTTP request with URI [ /artmuseum/i ndex.html] in DispatcherServlet with name 'springmvc' 大致意思是springmvc这个servlet处理不了index.html。原来是配置有问题。 看看web.xml配置,是这样写的: <!-- 注册前端控制器 --> < servlet > < servlet-name > springmvc </ servlet-name > < servlet-class > org.springframework.web.servlet.DispatcherServlet </ servlet-class > < init-param > <

Spring Boot Binder API support for @Value Annotations

試著忘記壹切 提交于 2021-02-11 13:12:40
问题 I am using the Spring Boot Binder API in an EnvironmentPostProcessor (i.e. before the actual application context(s) is (are) refreshed) to bind a custom ConfigurationProperty object. I want users to have to specify exactly one mandatory property in application.yml : com.acme.kafka.service-instance-name: <user-provided value> . Given that, I will be able to derive the other (required but not mandatory to be put in by the user) properties: com: acme: kafka: username: <can be fetched from VCAP

java消息队列--ActiveMQ

点点圈 提交于 2021-02-11 13:03:54
1、下载安装ActiveMQ   ActiveMQ官网下载地址: http://activemq.apache.org/download.html   ActiveMQ 提供了Windows 和Linux、Unix 等几个版本,楼主这里选择了Linux 版本下进行开发。   下载完安装包,解压之后的目录:     从它的目录来说,还是很简单的: bin存放的是脚本文件 conf存放的是基本配置文件 data存放的是日志文件 docs存放的是说明文档 examples存放的是简单的实例 lib存放的是activemq所需jar包 webapps用于存放项目的目录 2、启动ActiveMQ    进入到ActiveMQ 安装目录的Bin 目录,linux 下输入 ./activemq start 启动activeMQ 服务。    输入命令之后,会提示我们创建了一个进程IP 号,这时候说明服务已经成功启动了。      ActiveMQ默认启动时,启动了内置的jetty服务器,提供一个用于监控ActiveMQ的admin应用。   admin: http://127.0.0.1:8161/admin/   我们在浏览器打开链接之后输入账号密码(这里和tomcat 服务器类似)   默认账号:admin   密码:admin       到这里为止,ActiveMQ 服务端就启动完毕了。

Load multiple yaml file with same root key in spring boot

本秂侑毒 提交于 2021-02-11 13:01:45
问题 I'm looking for a solution in spring boot where I can maintain same root key in multiple files and load it to a POJO. application-profile-1.yml active: configuration: - name: abc ....... (1000 lines in config) application-profile-2.yml active: configuration: - name: xyz ....... (900 lines in config) application-profile-3.yml active: configuration: - name: abc ....... (700 lines in config) application.yml spring.profiles.include: profile-1,profile-2,profile-3 @ConfigurationProperties(prefix =

Spring boot JPA many to many with extra column insert and update issue

大城市里の小女人 提交于 2021-02-11 13:00:30
问题 Here is my initial question. Spring Data JPA Many to Many with extra column User and Roles Now I have the right tables created, but can't make it work for the update. Here is the code: User.java @Entity @Table(name = "users") public class User { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; private String username; @OneToMany(mappedBy="user", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY) private List<UserRole> roles; // getters and setters

Spring boot JPA many to many with extra column insert and update issue

耗尽温柔 提交于 2021-02-11 13:00:29
问题 Here is my initial question. Spring Data JPA Many to Many with extra column User and Roles Now I have the right tables created, but can't make it work for the update. Here is the code: User.java @Entity @Table(name = "users") public class User { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; private String username; @OneToMany(mappedBy="user", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY) private List<UserRole> roles; // getters and setters