Tag: spring boot

有一种简单的方法可以在Jhipster微服务网关上添加社交登录吗?

当我使用yo生成一个单一的应用程序时,我被问到是否要使用社交登录,但在微服务模型的网关创建过程中不会发生这种情况。 是否有一种在微服务网关上添加社交登录的简单方法,还是我需要手动创建?

Spring Security OAuth 2,带有表单登录

我正在尝试配置我的Spring启动应用程序以使用表单登录,并使用OAuth 2授权服务器validation凭据(将表单登录中的凭据发送到用户授权URL。 但是,当我使用以下SecurityConfig并且我转到资源时,而不是使用表单登录,它会重定向到授权服务器,询问我的凭据(使用基本身份validation),然后重定向回应用程序本身。 我正在使用以下SecurityConfig : @Configuration @EnableOAuth2Sso public class SecurityConfig extends OAuth2SsoConfigurerAdapter { @Override public void configure(HttpSecurity http) throws Exception { http .logout() .and() .antMatcher(“/**”) .authorizeRequests() .anyRequest().authenticated() .and() .csrf() .csrfTokenRepository(csrfTokenRepository()).and() .addFilterAfter(csrfHeaderFilter(), CsrfFilter.class) .formLogin(); } // CSRF repository + filter } 我将formLogin()提供给configure()方法,但这似乎不起作用。 以下配置位于我的application.yml文件中: spring: oauth2: client: clientId: test clientSecret: secret accessTokenUri: http://localhost:8081/uaa/oauth/token userAuthorizationUri: http://localhost:8081/uaa/oauth/authorize clientAuthenticationScheme: header […]

使用websphere 8.5.5进行Spring启动 – UOWManager事务处理失败

我在启动Web应用程序(通过URL)时遇到此exception,它似乎是JTA依赖问题,但我无法修复它。 这适用于Tomcat但在Websphere上失败。 堆栈跟踪 org.springframework.transaction.TransactionSystemException: UOWManager transaction processing failed; nested exception is com.ibm.wsspi.uow.UOWException: java.lang.LinkageError: com/ibm/websphere/uow/UOWSynchronizationRegistry.registerInterposedSynchronization(Ljavax/transaction/Synchronization;)V (loaded from file:/home/parag/IBM/WebSphere/AppServer/plugins/com.ibm.ws.runtime.jar by org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@52adb42a) called from class org.springframework.transaction.jta.WebSphereUowTransactionManager$UOWActionAdapter (loaded from file:/home/parag/IBM/WebSphere/AppServer/profiles/AppSrv01/installedApps/parag-desktopNode01Cell/eplvc-0_0_5_war.ear/eplvc-0.0.5.war/WEB-INF/lib/spring-tx-4.3.18.RELEASE.jar by com.ibm.ws.classloader.CompoundClassLoader@b0248555[appwar:eplvc-0_0_5_war] Parent: com.ibm.ws.classloader.ProtectionClassLoader@e95e3a61 Delegation Mode: PARENT_LAST). at org.springframework.transaction.jta.WebSphereUowTransactionManager.execute(WebSphereUowTransactionManager.java:300) ~[spring-tx-4.3.18.RELEASE.jar:4.3.18.RELEASE] at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:301) ~[spring-tx-4.3.18.RELEASE.jar:4.3.18.RELEASE] at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) ~[spring-tx-4.3.18.RELEASE.jar:4.3.18.RELEASE] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.18.RELEASE.jar:4.3.18.RELEASE] at org.springframework.aop.interceptor.AsyncExecutionInterceptor$1.call(AsyncExecutionInterceptor.java:115) ~[spring-aop-4.3.18.RELEASE.jar:4.3.18.RELEASE] at java.util.concurrent.FutureTask.run(FutureTask.java:277) [na:1.8.0] at java.lang.Thread.run(Thread.java:811) [na:2.9 (07-25-2018)] […]

订阅Spring Metrics频道

因此,根据Spring的文档,它将在REST端点和消息通道上发布指标。 REST端点工作正常,因为我得到了预期的结果。 但是,我想处理指标中的每个更改。 因此它表示默认情况下会将消息发布到名为“metricsChannel”的频道 我试图创建以下类来听这个频道,但它似乎没有激发。 其他所有内容都保留了Spring Boot应用程序的默认值。 package services.core; import org.springframework.stereotype.Service; import org.springframework.integration.annotation.ServiceActivator; @Service public class MetricService { @ServiceActivator(inputChannel = “metricsChannel”) public void handleMessage(org.springframework.messaging.Message message) { System.out.println(“Message [” + message.toString() + “] is received”); } }

对于预检,响应具有无效的HTTP状态代码401,用于oauth / token

我在spring boot中为CORS实现了Filter。代码如下: – @SpringBootApplication @Component public class Application implements Filter { public static void main(String[] args) { SpringApplication.run(Application.class, args); } @Override public void init(FilterConfig filterConfig) throws ServletException { } @Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) servletRequest; HttpServletResponse response = (HttpServletResponse) servletResponse; response.setHeader(“Access-Control-Allow-Origin”, “*”); response.setHeader(“Access-Control-Allow-Credentials”, […]

在spring-boot中侦听存储库事件

我正在尝试RepositoryEventListener在spring-boot应用程序中工作,但我想我做错了… 这是Listener中的代码 @SuppressWarnings(“rawtypes”) public class BeforeSaveEventListener extends AbstractRepositoryEventListener { @Override public void onBeforeSave(Object customer) { throw new RuntimeException(“++++ BEFORE SAVE EVENT ++++”); } } 这是我的Application类 @SpringBootApplication public class Application { public static void main(String[] args) { SpringApplication springApplication = new SpringApplication(Application.class); springApplication.addListeners(new BeforeSaveEventListener()); springApplication.run(args); } } 在保存操作中,我可以看到这些事件被触发: Current Event is org.springframework.data.rest.core.event.BeforeCreateEvent received! Current Event is […]

如何使用websockets从mysql获取实时通知更新?

从几天开始,我一直在搜索社交网络或Q / A网站如何获得实时通知。 我开始了解订阅者 – 发布者模式。 我开始知道使用WebSockets获取实时更新。 Websocket发布端点,客户端订阅该端点,并不断获取任何更改的更新。 但我从网上得到的例子都是聊天应用程序。 但我的要求是从MySQL DB获取实时通知。 所以我的想法很少 我是否正在使用WebSockets来满足正确的要求? 或者我的要求还有其他一些有效的方法吗? 如果这对我来说是有效的方式,我认为解决这个问题的模式是:WebSocket将连接到MySql并始终查找更改。 它还发布了我的客户端将始终寻找的端点。 提交给Mysql的任何更改都将反映在WebSocket中并导致客户端应用程序。 如果我的模式是正确的,我不知道如何将WebSocket连接到Mysql。 任何帮助/指导都非常感谢。 更新 : 经过一些网络搜索: 1.由于我为我的网站创建了Rest Webservices,AJAX是实现通知function而不是WebSockets的更好方法吗? 2. WebSockets是否比实现Rest端点的AJAX调用更复杂(因为两者的目的相同,是为了获取通知)?

Spring Boot Samples FileNot发现错误

我在关于spring boot项目的例子中。 我已经通过maven编译并创建了一个jar文件,但在运行尝试时出错。 https://github.com/spring-projects/spring-boot/tree/master/spring-boot-samples/spring-boot-sample-simple 项目文件夹: 错误: java -jar spring-boot-sample-simple-1.1.3.BUILD-SNAPSHOT.jar 014-06-25 09:10:00.653 ERROR 12028 — [ main] osboot.SpringApplication : Application startup failed ava.lang.IllegalStateException: Unable to load configuration files at org.springframework.boot.context.config.ConfigFileApplicationListener.addPropertySources(ConfigFileApplicationListener.java:158) at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEnvironmentPreparedEvent(ConfigFileApplicationListener.j va:138) at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEnvironmentPreparedEvent(ConfigFileApplicationListener.j va:131) at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEvent(ConfigFileApplicationListener.java:120) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:98) at org.springframework.boot.context.event.EventPublishingRunListener.publishEvent(EventPublishingRunListener.java:100) at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:59) at org.springframework.boot.SpringApplication.run(SpringApplication.java:277) at org.springframework.boot.SpringApplication.run(SpringApplication.java:944) at org.springframework.boot.SpringApplication.run(SpringApplication.java:933) at sample.simple.SampleSimpleApplication.main(SampleSimpleApplication.java:46) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at […]

多级进程内缓存的更好选择是什么?

在我的spring启动应用程序中,我需要实现进程内多级缓存以下是需要缓存的数据示例: 客户名称(密钥,字符串) – 数据实体名称(密钥,字符串) – config-1(值,JSONObject) – config-2(值,JSONObject) 我计划有几百个客户条目,每个条目最多有一百个“配置”JSONObjects 我正在寻找ehcache: Cache cache = manager.getCache(“sampleCache1”); Element element = new Element(“key1”, “value1”); cache.put(element); 在这种情况下,我会用“Customer_Name”代替“key1”,用“My Customer”代替“value1”,但是我需要构建一个层次结构: customer -data entity -config 我不知道如何用ehcache做到这一点。 我也不确定我是否有更好的选择。 有没有人用ehcache或任何其他库实现这样的多级分层缓存?

无法在Linux上使用spring boot启动tomcat

突然间我无法启动嵌入式tomcat。 我明白了: [main] ERROR oacoyote.http11.Http11NioProtocol – Failed to start end point associated with ProtocolHandler [“http-nio-86”] java.net.SocketException: Permission denied 我试过更改tomcat端口,我试过设置权限:chmod 777 src / -R 我使用linux Mint 17 我不知道该怎么做… 这是堆栈跟踪: [main] ERROR oacoyote.http11.Http11NioProtocol – Failed to start end point associated with ProtocolHandler [“http-nio-86”] java.net.SocketException: Permission denied at sun.nio.ch.Net.bind0(Native Method) ~[na:1.7.0_67] at sun.nio.ch.Net.bind(Net.java:444) ~[na:1.7.0_67] at sun.nio.ch.Net.bind(Net.java:436) ~[na:1.7.0_67] at […]