我正在尝试为我的spring项目创建一个连接,所以非常简单.
我想在application.properties上创建配置字段.我尝试了spring.datasource,我没有得到任何错误,但仍然,我没有得到任何信息,只是空指针...我认为连接没有正确.
这是我的pom的一部分,具有这种依赖关系:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>4.2.1.RELEASE</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.35</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
我的财产:
server.port=80
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/database
jdbc.username=user
jdbc.password=password
Run Code Online (Sandbox Code Playgroud)
我没有得到任何错误,但当我查询数据库时,我总是得到一个空指针,这让我觉得不能正常工作,任何想法如何配置这个?
谢谢
编辑:
我的配置类
@SpringBootApplication
public class Application {
public static void main(String[] args) {
ApplicationContext ctx = SpringApplication.run(Application.class, args);
}
}
Run Code Online (Sandbox Code Playgroud)
控制器
@Autowired
private MyService myService;
@RequestMapping("/")
public String index() {
User myUser = myService.findUserById(1L);
System.out.println(myUser);
return myUser.getFirstName();
}
Run Code Online (Sandbox Code Playgroud)
我的服务实施
@Service
public class MyServiceImpl implements MyService {
@Autowired
UserRepository userRepository; …Run Code Online (Sandbox Code Playgroud) 从那时起我一直在为肥皂客户工作,我仍然无法理解.
我有这个错误:
Exception in thread "main" java.lang.IllegalAccessError: tried to access field org.apache.cxf.staxutils.OverlayW3CDOMStreamWriter.isOverlaid from class org.apache.cxf.binding.soap.saaj.SAAJStreamWriter
at org.apache.cxf.binding.soap.saaj.SAAJStreamWriter.getPrefix(SAAJStreamWriter.java:79)
at org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor.writeSoapEnvelopeStart(SoapOutInterceptor.java:109)
at org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor.handleMessage(SoapOutInterceptor.java:87)
at org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor.handleMessage(SoapOutInterceptor.java:67)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)
at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:514)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:423)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:324)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:277)
at org.apache.cxf.endpoint.ClientImpl.invokeWrapped(ClientImpl.java:312)
at org.apache.cxf.jaxws.DispatchImpl.invoke(DispatchImpl.java:321)
at org.apache.cxf.jaxws.DispatchImpl.invoke(DispatchImpl.java:240)
at com.sigetel.web.web.rest.consumer.SoapClient.invoke(SoapClient.java:63)
at com.sigetel.web.web.rest.consumer.SoapClient.main(SoapClient.java:37)
Disconnected from the target VM, address: '127.0.0.1:60128', transport: 'socket'
Process finished with exit code 1
Run Code Online (Sandbox Code Playgroud)
我看到它有点普遍,但仍然无法使它工作.
这是我的代码:
Dispatch<SOAPMessage> dispatch = service.createDispatch(portName, SOAPMessage.class, Service.Mode.MESSAGE);
SOAPMessage response;
SOAPBody responseBody;
dispatch.getRequestContext().put(Dispatch.SOAPACTION_USE_PROPERTY, true);
dispatch.getRequestContext().put(Dispatch.SOAPACTION_URI_PROPERTY, soapActionUri);
try {
MessageFactory messageFactory = MessageFactory.newInstance(); …Run Code Online (Sandbox Code Playgroud) 我遇到了一个问题,我不知道是否有可能使用JPA.
我正在尝试使用JPA进行查询并进行以下操作:
获取课程实体字段(id,name)的所有课程,但也包含非持久字段(@Transient),其中将填写与此课程相关的所有学生的计数
像这样的东西:
List<Course> courses = courseRepository.findAll();
Run Code Online (Sandbox Code Playgroud)
但取而代之的是(以json为例)
[{1, soccer}, {2, art}, {3, singing}]
Run Code Online (Sandbox Code Playgroud)
我需要这样的东西
[{1, soccer, 2}, {2, art, 0}, {3, singing, 1}]
Run Code Online (Sandbox Code Playgroud)
如您所见,值为2,0 a 1是所有相关行的表学生的计数
Student table
| id | name | description | course |
| 1 | thg1 | a thing | 1 |
| 2 | thg2 | another one | 1 |
| 3 | thg3 | one more | 3 |
Course Table
| id | name |
| 1 | …Run Code Online (Sandbox Code Playgroud) 我想要安装ruby 2.0并且我已经遵循了许多教程,但是它们都没有工作,并且defaul repo apt-get install ruby带给我1.8版本(并且由于debian有限制更新它,如果不是通过repo)任何方式来做它?
我试过这种方式
cd /usr/src
wget ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p0.tar.gz
tar xjf ruby.xxx.tar.bz2
cd rubyxxx
./configure --enable-shared
make
make install
Run Code Online (Sandbox Code Playgroud)
就这样,我在接下来的步骤中得到错误,当我做一个ruby -version我得到了这个
-bash: /usr/bin/ruby: No such file or directory
Run Code Online (Sandbox Code Playgroud)
tuto安装结束
cd ext/openssl/
ruby extconf.rb
make install
cd ../readline/
ruby extconf.rb
make install
gem update --system
Run Code Online (Sandbox Code Playgroud)
任何想法如何在debian 6中这样做?谢谢
我试图用CodeIgniter进行分页,根据Codeigniter的手册应该这么简单,即使在这个例子中也是这样的
«首先<1 2 3 4 5>最后»
$config['total_rows'] = $this->searchdesc_model->queryallrows();
$config['per_page'] = '10';
$config['uri_segment'] =4;
$config['full_tag_open'] = '<p>';
$config['full_tag_close'] = '</p>';
$config['cur_tag_open'] = '<b>';
$config['cur_tag_close'] = '</b>';
$config['first_link'] = 'First';
$config['last_link'] = 'Last';
$config['last_tag_open'] = '<p>';
$config['last_tag_close'] = '</p>'
$this->load->library('Company_Creation');
Run Code Online (Sandbox Code Playgroud)
在视图中我只称它为pagination-> create_links(); ?>(或者当我从控制器调用它时,我通过视图发送它,但我只能得到它
1 2 3>
并且没有办法使它看起来像exmaple,可能听起来如此虚拟但是,任何人都可以帮助我吗?或者有类似的问题?
谢谢
编辑1
$config['total_rows'] = $this->searchdesc_model->queryallrows();
$config['per_page'] = '5';
$config['uri_segment'] =4;
$config['full_tag_open'] = '<p>';
$config['full_tag_close'] = '</p>';
$config['cur_tag_open'] = '<b>';
$config['cur_tag_close'] = '</b>';
$config['first_link'] = ' First';
$config['last_link'] = ' Last';
$config['last_tag_open'] = '<p>';
$config['last_tag_close'] …Run Code Online (Sandbox Code Playgroud) 我想使用laravel,所以,首先我必须安装作曲家,我上传laravel文件夹"laravel"现在我去文件夹,我这样做
curl -sS https://getcomposer.org/installer | php
Run Code Online (Sandbox Code Playgroud)
根据作曲家的网站...
所以,现在,根据laravel,我应该这样做
composer create-project laravel/laravel
Run Code Online (Sandbox Code Playgroud)
但返回"找不到composer命令"
当我完成安装作曲家后,我得到了这个使用它:php composer.phar
所以,我再试一次 php composer.phar create-project laravel/laravel
并且它运行,但它长时间保持为安装依赖项(包括require-dev).
我的环境是Debian 6,它是一个云服务器,因此,互联网应该不是问题.它只是那样,任何想法我做错了什么?如何解决这个问题并让它运行?
谢谢
我正在使用bitbucket并使用gitflow进行管理(或尝试).
我的问题是:我创建了我的功能,我做了一个
git-flow feature finish name
Run Code Online (Sandbox Code Playgroud)
所以,在我读过的教程中,我必须这样做
git push origin :feature/name
Run Code Online (Sandbox Code Playgroud)
在那之前,在bitbucket我可以看到分支,在做了git push origin后它被删除了,为什么?
完成该功能后,我应该运行push origin命令吗?
我已经有一个 .pem 和一个 .key 文件,我不想在本地安装/导入它,只需告诉我的客户使用它们,这可能吗?它不是自签名证书
基本上,在我的卷曲中,我做了这样的事情:
curl --key mykey.key --cert mycert.pem https://someurl.com/my-endpoint
Run Code Online (Sandbox Code Playgroud)
我已经检查过这个答案
还有这个https://github.com/square/okhttp/blob/master/samples/guide/src/main/java/okhttp3/recipes/CustomTrust.java(但可能没有意义,因为我没有得到该类型的对象我需要)
基本上我有我的 okHttpClient
val okHttpClient = OkHttpClient.Builder()
.sslSocketFactory(?, ?) //here I tried to call sslSocketFactory, trustManager following the example from the CustomTrust.java
.build()
Run Code Online (Sandbox Code Playgroud)
有什么解决方案的想法吗?
也检查了此文档,但 ssl 部分未完成,示例中也未完成
https://square.github.io/okhttp/https/#customizing-trusted-certificates-kt-java
所以我尝试这样做(基于 okhttp 示例)
private fun trustedCertificatesInputStream(): InputStream {
val comodoRsaCertificationAuthority = (""
+ "-----BEGIN CERTIFICATE-----\n" +
"-----END CERTIFICATE-----")
return Buffer()
.writeUtf8(comodoRsaCertificationAuthority)
.inputStream()
}
val loggingInterceptor = HttpLoggingInterceptor().apply {
level = HttpLoggingInterceptor.Level.BODY
}
fun createClient() : OkHttpClient …Run Code Online (Sandbox Code Playgroud) 我有这个问题,我想知道我的兔子工作得很好.
我不会发送消息,所以,我不是100%肯定正在发送.但问题是这个.
毕竟配置完毕......
我在RabbitMQ网站管理员看到了
当我据说发送消息时,我看到"消息率"图表上的活动,但"排队消息"中没有任何内容.
我坦率地不知道发生了什么,它是否太快而不需要排队消息?或者是错误配置的东西?
有什么不同的想法吗?
谢谢.
鉴于以下代码,有人可以解释为什么断言返回 true 吗?尽管已经进行了无数次搜索,但我无法得到任何适当的答案,说明为什么会出现这种情况,Java 特性是什么导致了这种行为,以及我在类似地创建这样的接口时会遇到哪些限制/要求作为这个。
interface X {
default int foo() {return 1;}
String bar();
}
public class Exercise{
public static void main(String[]arg){
X foo1=()->"hello";
assert (foo1.bar()).equals("hello");
}
}
Run Code Online (Sandbox Code Playgroud) java ×5
spring ×2
codeigniter ×1
composer-php ×1
cxf ×1
debian ×1
git ×1
git-flow ×1
jdbc ×1
jpql ×1
kotlin ×1
lambda ×1
laravel ×1
okhttp ×1
pagination ×1
php ×1
rabbitmq ×1
retrofit ×1
ruby ×1
search ×1
soap ×1
spring-mvc ×1
ssl ×1
web-services ×1