我声明我读过线程,但我从未使用过.所以我问你:)
我有两个线程:A和B,其中A管理GUI和B管理逻辑.
我会先说A.
然后在A绘制GUI时,我会暂停它,等待B到达X点进入run方法.
当B达到X点进入运行方法时,我暂停B,然后恢复A.
A并B共享一些变量来管理GUI,逻辑......
我可以做吗?如果有,怎么样?:)
spring.freemarker.cache:false
spring.datasource.url=jdbc:mysql://localhost/mydb
spring.datasource.username=user
spring.datasource.password=pass
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
Run Code Online (Sandbox Code Playgroud)
我甚至在驱动程序类名称的情况下得到此错误
java.lang.IllegalStateException:无法加载驱动程序类:com.mysql.jdbc.Driver at org.springframework.util.Assert.state(Assert.java:392)〜[spring-core-4.2.1.RELEASE.jar:4.2 .1.RELEASE] org.springframework.boot.autoconfigure.jdbc.DataSourceProperties.getDriverClassName(DataSourceProperties.java:153)〜[spring-boot-autoconfigure-1.3.0.M5.jar:1.3.0.M5] at org .springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration $ NonEmbeddedConfiguration.dataSource(DataSourceAutoConfiguration.java:119)〜[spring-boot-autoconfigure-1.3.0.M5.jar:1.3.0.M5] at sun.reflect.NativeMethodAccessorImpl. invoke0(Native Method)〜[na:1.8.0_60] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)〜[na:1.8.0_60] at ......
它继续下去
我正在使用keycloak 3.4并spring boot开发一个网络应用程序.我正在使用Active Directory作为用户Federeation来检索所有用户信息.
但是要在我的网络应用程序中使用这些信息,我想我必须将它们保存在"local-webapp"数据库中.
因此,在用户登录后,如何将其保存在我的数据库中?
我正在考虑这样的场景:"我有一个对象A,它引用了用户B,因此我必须在它们之间建立关系.所以我添加了一个外键."
在这种情况下,我需要让我的数据库上的用户.没有?
编辑
为了避免保存我的数据库上的所有用户,我正在尝试使用管理员API,因此我在控制器中添加了以下代码.
我还创建了另一个调用Test所有用户的客户端,这样我可以使用client-id和client-secret.或者有没有办法JWT使用admin api?
客户端:
Keycloak keycloak2 = KeycloakBuilder.builder()
.serverUrl("http://localhost:8080/auth/admin/realms/MYREALM/users")
.realm("MYREALMM")
.username("u.user")
.password("password")
.clientId("Test")
.clientSecret("cade3034-6ee1-4b18-8627-2df9a315cf3d")
.resteasyClient(new ResteasyClientBuilder().connectionPoolSize(20).build())
.build();
RealmRepresentation realm2 = keycloak2.realm("MYREALMM").toRepresentation();
Run Code Online (Sandbox Code Playgroud)
错误是:
2018-02-05 12:33:06.638 ERROR 16975 --- [nio-8080-exec-7] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Handler dispatch failed; nested exception is java.lang.Error: Unresolved compilation problem:
The method realm(String) is undefined for …Run Code Online (Sandbox Code Playgroud) has_and_belongs_to_many我的Ruby On Rails项目中存在关联问题.
这是我的模特:
class Store < ActiveRecord::Base
attr_accessible :address, :city, :map_url, :name, :uimage_url
has_and_belongs_to_many :furnitures_id
end
class Furniture < ActiveRecord::Base
attr_accessible :description, :image_url, :maintenance, :name, :size
has_and_belongs_to_many :store_id
end
Run Code Online (Sandbox Code Playgroud)
这是我的联接表迁移:
create_table "furnitures_stores", :id => false, :force => true do |t|
t.integer "furniture_id"
t.integer "store_id"
end
Run Code Online (Sandbox Code Playgroud)
然后我尝试使用seed.rb插入一些值:
Furniture.delete_all
furnitures = Furniture.create([{name: 'aaaa 1'}])
Store.delete_all
storee = Store.create([{name: 'S 1'}])
Run Code Online (Sandbox Code Playgroud)
但它不起作用; 我有这个错误:
**rake aborted!
uninitialized constant Store::FurnituresId**
Run Code Online (Sandbox Code Playgroud) 我用Spring MVC,JSP和Tyles创建了一个自定义标记库,所以我有几个.tagx文件.在新项目中,我决定尝试Spring Boot和Thymelaf,但我想保留我的自定义库......
如果可以使用thymleaf创建自定义标记库,那么你呢?或者,我是否可以以任何方式导入自定义标记库?
编辑
我添加一些代码以便更清楚.以下使用的标签是我的自定义标签.所以我把JSP包含在里面xmlns:form="urn:jsptagdir:/WEB-INF/tags/form"
<form:create id="fu_utente" modelAttribute="utente" path="/utente">
<div class="row">
<div class="col-md-12 text-center">
<h1 class="fa fa-user-plus" style="color:green;"><b>  Stai creando un nuovo utente di tipo: <var class="varFont"> ${utente.ruolo}</var></b></h1>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-4 col-md-offset-2">
<field:input field="nome" id="c_utente_nome" required="true"/>
</div>
<div class="col-xs-12 col-sm-12 col-md-4">
<field:input field="userName" id="c_utente_username" min="5" max="15" required="true"/>
</div>
<div class="col-xs-12 col-sm-12 col-md-8 col-md-offset-2">
<field:input field="email" id="c_Utente_email" required="true" validationRegex="^[a-z0-9_\+-]+(\.[a-z0-9_\+-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*\.([a-z]{2,4})$"/>
</div>
<div class="col-xs-12 col-sm-12 col-md-4 col-md-offset-2">
<field:input field="nuovaPassword" id="c_utente_password" min="6" max="15" required="true" type="password"/>
</div>
<div …Run Code Online (Sandbox Code Playgroud) 我在Ubuntu上运行我的代码,我需要在程序中获取有关函数的已用时间.我需要一个非常准确的时间,如纳秒或至少微秒.
我读过chrono.h但它使用系统时间,我更喜欢使用CPU时间.
有没有办法做到这一点,并具有那种粒度(纳秒)?
我正在开发一个有3个数据源的网络应用程序:我们可以称之为DS1,DS2和DS3.它们中的每一个都是物理数据库.
所以我为每个数据源添加了一个配置,使用不同的实体管理器等等.
在DS1里面我有实体E1,而在第二个数据源里面我有E2.现在我需要在这两个实体之间创建一个关系.
所以我添加了类似的东西:
public class E1 {
...
@OneToOne
private E2 e2;
...
}
Run Code Online (Sandbox Code Playgroud)
但是我有以下错误:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManager' defined in class path resource [it/mux/config/datasource/DataSourceMuxConfig.class]: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: @OneToOne or @ManyToOne on it.mux.domain.amministrazione.Bo.e2 references an unknown entity: it.mux.cliente.domain.E2
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) …Run Code Online (Sandbox Code Playgroud) 我将此查询与 Jpa 存储库一起使用:
@Query("select f.attrezzature from FoglioLavoro f where f.id = :idFoglioLavoro")
Page<AbstractAttrezzatura> findAttrezzaturaFoglioLavoro(@Param("idFoglioLavoro")Long idFoglioLavoro, Pageable pageable);
Run Code Online (Sandbox Code Playgroud)
但是当我使用这个查询时,我得到了这个错误:
ERROR: org.hibernate.engine.jdbc.spi.SqlExceptionHelper - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') as col_0_0_ from foglio_lavoro fogliolavo0_, foglio_lavoro_attrezzature attrez' at line 1
Run Code Online (Sandbox Code Playgroud)
这是生成的 spring-data 查询:
Hibernate:
select
count(.) as col_0_0_
from
foglio_lavoro fogliolavo0_,
foglio_lavoro_attrezzature attrezzatu1_,
abstract_attrezzatura abstractat2_
where
fogliolavo0_.id=attrezzatu1_.fogli_lavoro
and attrezzatu1_.attrezzature=abstractat2_.id
and fogliolavo0_.id=?
Run Code Online (Sandbox Code Playgroud)
我该如何解决??非常感谢
嗨,我使用此配置Spring Security:
<http auto-config="true" use-expressions="true">
<session-management>
<concurrency-control max-sessions="1" />
</session-management>
<form-login login-page="/login" login-processing-url="/resources/j_spring_security_check" authentication-failure-url="/login?login_error=t"/>
<logout logout-url="/resources/j_spring_security_logout"/>
<intercept-url pattern="/resources/**" access="permitAll" />
<intercept-url pattern="/login" access="permitAll" />
<intercept-url pattern="/**" access="isAuthenticated()" />
</http>
Run Code Online (Sandbox Code Playgroud)
如果在我的标题请求中,我需要返回一个Http Error Code类似的内容:否则我想重定向到Login Page.401Content-Typeapplication/json;
但是使用此配置,无论请求内容类型如何,我都会被重定向到具有302响应代码的登录URL .
有没有办法做到这一点??
编辑: 我想只使用一个servlet来处理html和json所以我试试这个:
@Component
public class CustomEntryPoint extends LoginUrlAuthenticationEntryPoint {
private final Logger log = LoggerFactory.getLogger(CustomEntryPoint.class);
public CustomEntryPoint(String loginFormUrl) {
super(loginFormUrl);
}
@Override
public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException)
throws IOException, ServletException {
if(request.getContentType() …Run Code Online (Sandbox Code Playgroud) 我不知道为什么但是我无法使用spring boot和query dsl生成查询类.
这是我的pom.xml:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-core</artifactId>
<version>4.1.4</version>
</dependency>
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-apt</artifactId>
<version>4.1.4</version>
</dependency>
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-jpa</artifactId>
<version>4.1.4</version>
</dependency>
<!-- Joda-time -->
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.9.9</version> …Run Code Online (Sandbox Code Playgroud) 我正在尝试读取这样的txt文件的数量:
input=20
output=10
hidden=5
....
Run Code Online (Sandbox Code Playgroud)
我试过这段代码:
char line[30];
char values[100][20];
int i = 0;
FILE *fp;
fp = fopen("myFile.txt", "r");
if(fp == NULL)
{
printf("cannot open file\n");
return 0;
}
while(fgets(line, sizeof(line), fp) != NULL)
{
sscanf(line, "%[^=]", values[i])
printf("%s\n", values[i]);
i++;
}
fclose(fp);
Run Code Online (Sandbox Code Playgroud)
但我只得到第一个字,而不是后面的数字=.
我明白了
input
output
etc
Run Code Online (Sandbox Code Playgroud)
代替
20
10
5
etc
Run Code Online (Sandbox Code Playgroud)
我怎么能得到这个数字?
spring ×7
spring-boot ×4
java ×3
hibernate ×2
associations ×1
c ×1
c++ ×1
datasource ×1
elapsedtime ×1
jpa ×1
keycloak ×1
many-to-many ×1
maven ×1
querydsl ×1
repository ×1
ruby ×1
scanf ×1
spring-mvc ×1
sql ×1
taglib ×1
tagx ×1
thymeleaf ×1
time ×1