我有两个用这些语句创建的表:
CREATE TABLE Behandlungsvorgang (
patientId SMALLINT NOT NULL REFERENCES Patient(id),
datum DATE NOT NULL,
notizen VARCHAR(100),
PRIMARY KEY (patientId, datum)
);
CREATE TABLE behandelt (
arztLogin VARCHAR(50) NOT NULL REFERENCES Arzt(login),
behandlungsDatum DATE NOT NULL,
behandlungsPatientId SMALLINT NOT NULL,
medikamntPzn SMALLINT NOT NULL REFERENCES Medikament(pzn),
krankheitName VARCHAR(50) NOT NULL REFERENCES Krankheit(name),
PRIMARY KEY (arztLogin, behandlungsDatum, behandlungsPatientId, medikamntPzn, krankheitName),
FOREIGN KEY (behandlungsDatum, behandlungsPatientId) REFERENCES Behandlungsvorgang(datum, patientId)
);
Run Code Online (Sandbox Code Playgroud)
我有一个方法应该将数据插入到这个表中.它总是插入新数据所以在插入之前behandelt我必须插入Behandlungsvorgang以满足外键要求.该方法如下所示:
public void add(TreatmentProcess tp) throws StoreException {
try …Run Code Online (Sandbox Code Playgroud) 我有application.yml,代码如下:
logging:
file: logs/keyserver.log
level:
org.springframework.web: 'DEBUG'
Run Code Online (Sandbox Code Playgroud)
它工作正常,除了这种情况:
public class TransactionBuilder extends Wallet {
private final Logger LOG = LoggerFactory.getLogger(TransactionBuilder.class);
@Override
public RedeemData findRedeemDataFromScriptHash(byte[] payToScriptHash) {
LOG.debug("payToScriptHash = " + HEX.encode(payToScriptHash));
}
}
Run Code Online (Sandbox Code Playgroud)
消息既不出现在日志文件中也不出现在屏幕上.
然而
LOG.info("payToScriptHash = " + HEX.encode(payToScriptHash));
LOG.error("payToScriptHash = " + HEX.encode(payToScriptHash));
Run Code Online (Sandbox Code Playgroud)
工作得很好.
我正在尝试在第二台计算机上安装我的rails应用程序.但是当我运行时,bundle install我得到了json gem的错误:
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/Users/feuerball/.rvm/rubies/ruby-2.0.0-p195/bin/ruby extconf.rb
/Users/feuerball/.rvm/rubies/ruby-2.0.0-p195/bin/ruby: invalid option -D (-h will show valid options) (RuntimeError)
Gem files will remain installed in /Users/feuerball/.rvm/gems/ruby-2.0.0-p195/gems/json-1.8.0 for inspection.
Results logged to /Users/feuerball/.rvm/gems/ruby-2.0.0-p195/gems/json-1.8.0/ext/json/ext/generator/gem_make.out
An error occurred while installing json (1.8.0), and Bundler cannot continue.
Make sure that `gem install json -v '1.8.0'` succeeds before bundling.
Run Code Online (Sandbox Code Playgroud)
该计算机使用Xcode 4.6.3和最新的命令行工具运行Mac OS X 10.8.4.
我使用rvm安装了最新的ruby:
$ rvm -v
rvm 1.21.2 (stable) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> …Run Code Online (Sandbox Code Playgroud) 我正在使用带有WAFFLE过滤器的Spring Security,该过滤器针对ActiveDirectory服务器对用户进行身份验证.我创建了一个额外的过滤器,它也根据我的数据库对用户进行身份验证(它只是检查以前经过身份验证的用户是否在数据库中).这是使用的实现完成的UserDetailsService.
这个组合一直有效,直到我向@Transactional服务添加了带注释的方法.现在,该服务无法自动连接到过滤器.
这是服务类:
@Service
public class UserService implements UserDetailsService {
@Autowired
private UserRepository userRepository;
@Autowired
private LdapUserDao ldapUserDao;
@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
return getUserByUsername(username);
}
public User getUserByUsername(final String username) {
final User databaseUser = userRepository.findByUsername(username);
final User ldapUser = ldapUserDao.findByUsername(username);
if (null == databaseUser || null == ldapUser) {
return null;
}
final User user = mergeUsers(databaseUser, ldapUser);
return user;
}
public List<User> getAllUsers() {
return userRepository.findAll();
}
@Transactional
public …Run Code Online (Sandbox Code Playgroud) 我有两个相关的模型:
class User < ActiveRecord::Base
belongs_to :role, dependent: :destroy, polymorphic: true
validates :role, presence: true
end
class Admin < ActiveRecord::Base
has_one :user, as: :role
attr_accessible :user_attributes
accepts_nested_attributes_for :user
end
Run Code Online (Sandbox Code Playgroud)
如果我保存管理员,如何验证用户是否存在?
更新
这是我的测试:
factories.rb
FactoryGirl.define do
sequence :email do |n|
"foo#{n}@example.com"
end
factory :user do
email
password "secret12"
password_confirmation "secret12"
factory :admin_user do
association :role, factory: :admin
end
end
factory :admin do
first_name "Max"
last_name "Mustermann"
end
end
Run Code Online (Sandbox Code Playgroud)
user_spec.rb
require "spec_helper"
describe User do
let(:user) { FactoryGirl.build(:user) }
let(:admin) { FactoryGirl.build(:admin_user) …Run Code Online (Sandbox Code Playgroud) 我正在FormComponentPanel为Wicket 建立一个定制.这是在自己的Maven项目中完成的.该项目后来作为依赖项添加到我的webapp中.目前,我的自定义面板不包含额外功能.我在同一个包里面有以下文件(在src/main/java/package下).
CustomFormPanel.java:
class CustomFormPanel extends FormComponentPanel<String> {
public CustomFormPanel(final String id) {
super(id);
}
}
Run Code Online (Sandbox Code Playgroud)
CustomFormPanel.html:
<wicket:panel>
</wicket:panel>
Run Code Online (Sandbox Code Playgroud)
我使用这个组件如下:
CustomPage.java:
public class CustomPage extends WebPage {
private final StatelessForm<Void> form;
private FormComponentPanel<String> customPanel;
public CustomPage(final PageParameters params) {
super(params);
customPanel = new CustomFormPanel("customPanel");
form = new StatelessForm<Void>("form") {
@Override
public void onSubmit() {
final String param = customPanel.getModelObject();
}
};
}
@Override
public void onInitialize() {
super.onInitialize();
form.add(customPanel);
add(form);
}
}
Run Code Online (Sandbox Code Playgroud)
CustomPage.html:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html> …Run Code Online (Sandbox Code Playgroud) 我正在尝试从 Java 程序运行一些 Mercurial 命令。我Process使用ProcessBuilder这样的方法构建我的:
final ProcessBuilder procBuilder = new ProcessBuilder("hg", "log");
procBuilder.directory(new File("/Users/feuerball/workspace/www"));
final Process proc = procBuilder.start();
Run Code Online (Sandbox Code Playgroud)
该文件夹www包含 Mercurial 存储库,hg已安装并在系统中PATH。但是当我开始这个过程时,我的程序抛出了一个异常。这是堆栈跟踪:
Exception in thread "main" java.io.IOException: Cannot run program "hg" (in directory "/Users/feuerball/workspace/www"): error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1042)
at de.feuerball.tests.Test.main(Test.java:16)
Caused by: java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:185)
at java.lang.ProcessImpl.start(ProcessImpl.java:134)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1023)
... 1 more
Run Code Online (Sandbox Code Playgroud)
为什么我会收到这个错误?
更新
为了表明该目录确实存在,我对代码进行了一些更改:
final File …Run Code Online (Sandbox Code Playgroud) 我想使用构造函数注入将字符串注入到 bean 中。基本上我有以下课程:
@Component
@StepScope
public class MyClass {
public MyClass (@Value("#{jobParameters['directory']}") final String directory) {
// ...
}
}
Run Code Online (Sandbox Code Playgroud)
当我运行我的应用程序时,我得到以下堆栈跟踪:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.byteArrayItemReader' defined in file [...]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [my.package.MyClass]: No default constructor found; nested exception is java.lang.NoSuchMethodException: my.package.MyClass.<init>()
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1105) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1050) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$2.getObject(AbstractBeanFactory.java:345) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.batch.core.scope.StepScope.get(StepScope.java:113) ~[spring-batch-core-3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:340) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.aop.target.SimpleBeanTargetSource.getTarget(SimpleBeanTargetSource.java:35) ~[spring-aop-4.2.3.RELEASE.jar:4.2.3.RELEASE] …Run Code Online (Sandbox Code Playgroud) 我想使用JDBC 4.1驱动程序连接到PostgreSQL数据库.我在以下内容中声明了以下依赖项pom.xml:
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.3-1101-jdbc41</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
这将postgresql-9.3-1101-jdbc41.jar进入我的类路径.我已经读过,Class.forName()如果指定了驱动程序,则不再需要加载驱动程序META-INF/services/java.sql.Driver.driver-jar有这个文件,但我仍然收到以下错误:
No suitable driver found for jdbc:postgresql://localhost:5432
Run Code Online (Sandbox Code Playgroud)
我只是在测试中调用然后使用mvn test以下命令运行测试:
DriverManager.getConnection("jdbc:postgresql://localhost:5432");
Run Code Online (Sandbox Code Playgroud)
即使我Class.forName()在收到错误之前打电话.如何正确加载驱动程序?
我有一个带有一些文本字段的表单.在字段中输入任何内容都是有效的,但我想获得空字符串.Wicket自动将空字符串转换为null.我发现FormComponents有一个叫做的标志FLAG_CONVERT_EMPTY_INPUT_STRING_TO_NULL.我认为这面旗帜是我的问题的原因.
但是我怎么能覆盖这个标志呢?是否有针对此的全球Wicket设置?
我正在使用 Spring Security 与 Waffle 相结合来对我的 web 应用程序的用户进行身份验证。我使用以下配置配置了 Spring Security:
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.annotation.web.servlet.configuration.EnableWebMvcSecurity;
import org.springframework.security.web.authentication.www.BasicAuthenticationFilter;
import waffle.servlet.spi.BasicSecurityFilterProvider;
import waffle.servlet.spi.NegotiateSecurityFilterProvider;
import waffle.servlet.spi.SecurityFilterProvider;
import waffle.servlet.spi.SecurityFilterProviderCollection;
import waffle.spring.NegotiateSecurityFilter;
import waffle.spring.NegotiateSecurityFilterEntryPoint;
import waffle.windows.auth.impl.WindowsAuthProviderImpl;
@Configuration
@EnableWebMvcSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private NegotiateSecurityFilterEntryPoint entryPoint;
@Autowired
private NegotiateSecurityFilter filter;
@Override
protected void configure(HttpSecurity http) throws Exception {
http.exceptionHandling().authenticationEntryPoint(entryPoint);
http.addFilterBefore(filter, BasicAuthenticationFilter.class).authorizeRequests().anyRequest()
.fullyAuthenticated();
}
@Bean
public WindowsAuthProviderImpl windowsAuthProviderImpl() {
return new WindowsAuthProviderImpl();
}
@Bean
public NegotiateSecurityFilterProvider negotiateSecurityFilterProvider(final …Run Code Online (Sandbox Code Playgroud) 我有以下Maven项目结构:
parent_project
+--main_application
+--domain_models_and_repository
+--module_1
+--module_2
+--module_3
Run Code Online (Sandbox Code Playgroud)
以下简化的POMS:
parent_project.pom
<project>
<dependencies>
[Spring Boot dependencies]
</dependencies>
<modules>
<module>main_application</module>
<module>domain_models_and_repository</module>
<module>module_1</module>
<module>module_2</module>
<module>module_3</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Run Code Online (Sandbox Code Playgroud)
main_application
<project>
<parent>
<artifactId>parent_project</artifactId>
</parent>
<dependencies>
<dependency>
<artifactId>domain_models_and_repository</artifactId>
</dependency>
<dependency>
<artifactId>module_1</artifactId>
</dependency>
<dependency>
<artifactId>module_2</artifactId>
</dependency>
<dependency>
<artifactId>module_3</artifactId>
</dependency>
</dependencies>
</project>
Run Code Online (Sandbox Code Playgroud)
module_1
<project>
<parent>
<artifactId>parent_project</artifactId>
</parent>
<dependencies>
<dependency>
<artifactId>domain_models_and_repository</artifactId>
</dependency>
</dependencies>
</project>
Run Code Online (Sandbox Code Playgroud)
module_2
<project>
<parent>
<artifactId>parent_project</artifactId>
</parent>
<dependencies>
<dependency>
<artifactId>domain_models_and_repository</artifactId>
</dependency>
</dependencies>
</project>
Run Code Online (Sandbox Code Playgroud)
module_3
<project>
<parent>
<artifactId>parent_project</artifactId>
</parent>
<dependencies>
<dependency> …Run Code Online (Sandbox Code Playgroud) 我想每当用户点击按钮时就增加 int 变量的值,但现在该值仅增加一次。
这就是我用来增加变量值的方法p。
@Override
public void onClick(View v) {
int p = 1;
if (p == 9) {
Toast.makeText(context, "You have reached to maximum number", Toast.LENGTH_LONG).show();
} else {
p = p + 1;
holder.textViewQuantity.setText("" + p);
}
}
Run Code Online (Sandbox Code Playgroud)