我尝试通过STOMP与服务器连接,但是收到“丢失的连接”消息以及任何特定信息。
WebSocket配置:
@Configuration
@EnableWebSocketMessageBroker
public class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer {
@Override
public void configureMessageBroker(MessageBrokerRegistry registry) {
registry.enableStompBrokerRelay("/topic", "/queve")
.setClientLogin("quest")
.setClientPasscode("quest");
registry.setApplicationDestinationPrefixes("/app");
}
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/hello").setAllowedOrigins("*").withSockJS();
}
}
Run Code Online (Sandbox Code Playgroud)
控制器:
@Controller
public class HelloController {
@MessageMapping("/hello")
public void greeting(HelloMessage message){
System.out.println("Wiadomosc: " + message.getName());
}
@SubscribeMapping({"/helloSub"})
public HelloMessage handleSubscription() {
HelloMessage outgoing = new HelloMessage();
System.out.println("SUB");
outgoing.setName("Jas");
return outgoing;
}
}
Run Code Online (Sandbox Code Playgroud)
js脚本:
var sock = new SockJS("http://localhost:8080/BuyMyTime/hello");
var stomp = Stomp.over(sock);
var payload = JSON.stringify({'name':'Jasiek'});
stomp.connect('quest', 'quest', function(frame){ …Run Code Online (Sandbox Code Playgroud) 你知道一些用 Golang 编写的类似于 Spring Data JPA 的框架吗?我正在寻找可以让我在 Golang 结构和 MySQL 数据库表之间轻松工作的东西。我在谷歌上找,没找到。干杯。
好像我禁用了 jpa 存储库。有这个错误:
严重:StandardWrapper.Throwable org.springframework.beans.factory.UnsatisfiedDependencyException:在文件 [C:\Users\jasiu\workspace2.metadata.plugins\org.eclipse.wst.server.core\ tmp0\wtpwebapps\BuyMyTime\WEB-INF\classes\web\UserController.class]:不满足的依赖通过构造函数参数 0 表示:没有为依赖 [data.UserRepository] 找到类型为 [data.UserRepository] 的合格 bean:预期至少为 1 bean 有资格作为此依赖项的自动装配候选者。依赖注解:{}; 嵌套异常是 org.springframework.beans.factory.NoSuchBeanDefinitionException:没有为依赖项 [data.UserRepository] 找到类型为 [data.UserRepository] 的合格 bean:预期至少有 1 个 bean 有资格作为此依赖项的自动装配候选者。
配置:
@Configuration
@EnableTransactionManagement
@EnableJpaRepositories(basePackages={"data"})
@ComponentScan(basePackages={"data"},
excludeFilters={
@Filter(type=FilterType.ANNOTATION, value = EnableWebMvc.class)
})
public class RootConfig {
@Bean
public JpaTransactionManager transactionManager(EntityManagerFactory emf, DataSource dataSource){
JpaTransactionManager transactionManager = new JpaTransactionManager();
transactionManager.setEntityManagerFactory(emf);
transactionManager.setDataSource(dataSource);
return transactionManager;
}
@Bean
public DataSource dataSource() {
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName("com.mysql.jdbc.Driver");
dataSource.setUrl("jdbc:mysql://localhost:3306/HelloWorld");
dataSource.setUsername("login");
dataSource.setPassword("haslo");
return dataSource;
}
@Bean
public LocalContainerEntityManagerFactoryBean …Run Code Online (Sandbox Code Playgroud)