小编Nuñ*_*ada的帖子

你如何在Sequel Pro中执行查询?

我想使用Sequel Pro在MySQL数据库中执行查询,但我没有看到Run按钮.

我该如何执行查询?

在此输入图像描述

mysql sequelpro

57
推荐指数
3
解决办法
2万
查看次数

Java 8 Lambda:比较器

我想用Lambda对列表进行排序:

List<Message> messagesByDeviceType = new ArrayList<Message>();      
messagesByDeviceType.sort((Message o1, Message o2)->o1.getTime()-o2.getTime());
Run Code Online (Sandbox Code Playgroud)

但是我得到了这个编译错误:

 Multiple markers at this line
    - Type mismatch: cannot convert from long to int
    - The method sort(Comparator<? super Message>) in the type List<Message> is not applicable for the arguments ((Message o1, Message o2) 
     -> {})
Run Code Online (Sandbox Code Playgroud)

java lambda comparator java-8

43
推荐指数
4
解决办法
3万
查看次数

RestClientException:无法提取响应.找不到合适的HttpMessageConverter

使用curl命令:

curl -u 591bf65f50057469f10b5fd9:0cf17f9b03d056ds0e11e48497e506a2 https://backend.tdk.com/api/devicetypes/59147fd79e93s12e61499ffe/messages
Run Code Online (Sandbox Code Playgroud)

我收到了JSON响应:

{"data":[{"device":"18SE62","time":1494516023,"data":"3235","snr":"36.72",...
Run Code Online (Sandbox Code Playgroud)

我将响应保存在txt文件中并使用jackson解析它,一切都很好

ObjectMapper mapper = new ObjectMapper();
        File f = new File(getClass().getResource
                    ("/result.json").getFile());
        MessageList messageList = mapper.readValue(f, MessageList.class);
Run Code Online (Sandbox Code Playgroud)

我假设我应该使用RestTemplate获得相同的结果但事实并非如此

RestTemplate restTemplate = new RestTemplate();
        MessageList messageList = 
                restTemplate.getForObject("http://592693f43c87815f9b8145e9:f099c85d84d4e325a2186c02bd0caeef@backend.tdk.com/api/devicetypes/591570373c87894b4eece34d/messages", MessageList.class);
Run Code Online (Sandbox Code Playgroud)

我得到了一个错误

Exception in thread "main" org.springframework.web.client.RestClientException: Could not extract response: no suitable HttpMessageConverter found for response type [class com.tdk.domain.backend.MessageList] and content type [text/html;charset=iso-8859-1]
    at org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:109)
    at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:655)
    at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:613)
    at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:287)
    at com.tdk.controllers.restful.client.RestTemplateExample.main(RestTemplateExample.java:27)
Run Code Online (Sandbox Code Playgroud)

我试着设置contentType:

HttpHeaders headers = new HttpHeaders();
        headers.setContentType(MediaType.APPLICATION_JSON);
        HttpEntity<String> entity = new HttpEntity<String>("parameters", …
Run Code Online (Sandbox Code Playgroud)

rest spring json spring-mvc resttemplate

39
推荐指数
5
解决办法
10万
查看次数

SpringBoot:无法从以下候选者中找到单个主类

我使用Spring Initializer,嵌入式Tomcat,Thymeleaf模板引擎生成了Spring Boot Web应用程序.使用的技术:Spring Boot 1.4.2.RELEASE,Spring 4.3.4.RELEASE,Thymeleaf 2.1.5.RELEASE,Tomcat Embed 8.5.6 ,Maven 3,Java 8

我有一个SpringBoot应用程序.有这两个类:

@Profile("!war")
@SpringBootApplication
@Import({SecurityConfig.class ,PersistenceConfig.class, ServiceConfig.class})
public class BookApplication {

    public static void main(String[] args) {
        SpringApplication.run(BookApplication.class, args);
    }
}

@Profile("war")
@Import({SecurityConfig.class ,PersistenceConfig.class})
@SpringBootApplication
public class BookApplicationWar extends SpringBootServletInitializer {

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(BookApplicationWar.class);
    }

    public static void main(String[] args) throws Exception {
        SpringApplication.run(BookApplicationWar.class, args);
    }

}
Run Code Online (Sandbox Code Playgroud)

我用这个命令生成战争

 mvn clean package -DskipTests -Dspring.profiles.active=pebloc,war -DAPP-KEY=pebloc
Run Code Online (Sandbox Code Playgroud)

但我得到了这个错误:

[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.5.2.RELEASE:repackage (default) on …
Run Code Online (Sandbox Code Playgroud)

spring spring-mvc maven spring-profiles spring-boot

23
推荐指数
7
解决办法
3万
查看次数

使用 spring-jcl 进行标准共享日志记录发现

我有一个带有这些依赖项的 springBoot:

<dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</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-validation</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.28</version>
            <scope>provided</scope>
        </dependency>

        <!-- https://mvnrepository.com/artifact/com.mashape.unirest/unirest-java -->
        <dependency>
            <groupId>com.mashape.unirest</groupId>
            <artifactId>unirest-java</artifactId>
            <version>1.4.9</version>
        </dependency>

        <dependency>
            <groupId>com.mysql</groupId>
            <artifactId>mysql-connector-j</artifactId>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>io.jsonwebtoken</groupId>
            <artifactId>jjwt-api</artifactId>
            <version>0.11.5</version>
        </dependency>

        <dependency>
            <groupId>io.jsonwebtoken</groupId>
            <artifactId>jjwt-impl</artifactId>
            <version>0.11.5</version>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>io.jsonwebtoken</groupId>
            <artifactId>jjwt-jackson</artifactId>
            <version>0.11.5</version>
            <scope>runtime</scope>
        </dependency>


        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
Run Code Online (Sandbox Code Playgroud)

但我在控制台上有这样的消息:

Standard Commons Logging discovery in action with spring-jcl: please remove …
Run Code Online (Sandbox Code Playgroud)

java logging spring-boot

20
推荐指数
1
解决办法
3万
查看次数

Mac OSX - 打开一个端口

我想打开Mac的端口25,所以我编辑了文件 /etc/pf.conf

MacBook-Pro-de-nunito:~ calzada$ more /etc/pf.conf
#
# Default PF configuration file.
#
# This file contains the main ruleset, which gets automatically loaded
# at startup.  PF will not be automatically enabled, however.  Instead,
# each component which utilizes PF is responsible for enabling and disabling
# PF via -E and -X as documented in pfctl(8).  That will ensure that PF
# is disabled only when the last enable reference is released.
#
# Care must be taken to …
Run Code Online (Sandbox Code Playgroud)

macos

18
推荐指数
1
解决办法
2万
查看次数

错误:无法从Oracle WebLogic Server 12.1.3.0开始两次加载此JVM TI代理

我正在启动Oracle WebLogic Server 12.1.3.0,我已经托管了一些WEb应用程序,但我无法启动它,因为我有一个错误

使用Java版本启动weblogic:

%JAVA_HOME%\bin\java %JAVA_VM% -version

if "%WLS_REDIRECT_LOG%"=="" (
    echo Starting WLS with line:
    echo %JAVA_HOME%\bin\java %JAVA_VM% %MEM_ARGS% -Dweblogic.Name=%SERVER_NAME% -Djava.security.policy=%WLS_POLICY_FILE% %JAVA_OPTIONS% %PROXY_SETTINGS% %SERVER_CLASS%
    %JAVA_HOME%\bin\java %JAVA_VM% %MEM_ARGS% -Dweblogic.Name=%SERVER_NAME% -Djava.security.policy=%WLS_POLICY_FILE% %JAVA_OPTIONS% %PROXY_SETTINGS% %SERVER_CLASS%
) else (
    echo Redirecting output from WLS window to %WLS_REDIRECT_LOG%
    %JAVA_HOME%\bin\java %JAVA_VM% %MEM_ARGS% -Dweblogic.Name=%SERVER_NAME% -Djava.security.policy=%WLS_POLICY_FILE% %JAVA_OPTIONS% %PROXY_SETTINGS% %SERVER_CLASS%  >"%WLS_REDIRECT_LOG%" 2>&1 
)
Run Code Online (Sandbox Code Playgroud)

但我得到了这个错误:

C:\myprograms\Tools\tracesnt>startWebLogic.cmd
.
.
JAVA Memory arguments: -Xms256m -Xmx512m -XX:CompileThreshold=8000 -XX:PermSize=128m  -XX:MaxPermSize=256m
.
CLASSPATH=C:\PROGRA~2\Java\JDK18~1.0_6\lib\tools.jar;C:\myprograms\Tools\wls12130\wlserver\server\lib\weblogic_sp.jar;C:\myprograms\Tools\wls12130\wlserver\server\lib\weblogic.jar;C:\myprograms\Tools\wls12130\wlserver\server\lib\webservices.jar;C:\myprograms\Tools\wls12120\oracle_common\modules\org.apache.ant_1.7.1/lib/ant-all.jar;C:\myprograms\Tools\wls12120\oracle_common\modules\net.sf.antcontrib_1.1.0.0_1-0b2/lib/ant-contrib.jar
;C:\myprograms\Tools\wls12130\wlserver\modules\features\oracle.wls.common.nodemanager_1.0.0.0.jar;C:\myprograms\Tools\wls12120\oracle_common\modules\com.oracle.cie.config-wls-online_8.1.0.0.jar;C:\myprograms\Tools\wls12130\wlserver\common\derby\lib\derbyclient.jar;C:\myprograms\Tools\wls12130\wlserver\common\derby\lib\derby.jar;C:\myprograms\Tools\wls12130\wlserver\server\lib\xqrl.jar
.
PATH=;C:\myprograms\Tools\wls12130\wlserver\server\native\win\32;C:\myprograms\Tools\wls12130\wlserver\server\bin;C:\myprograms\Tools\wls12120\oracle_common\modules\org.apache.ant_1.7.1\bin;C:\PROGRA~2\Java\JDK18~1.0_6\jre\bin;C:\PROGRA~2\Java\JDK18~1.0_6\bin;C:\PROGRA~3\Oracle\Java\javapath;C:\myprograms\Oracle\product\112~1.0\CLIENT~1\bin;C:\Windows\System32;C:\Windows;C:\Windows\System32\wbem;C:\Windows\System32\WINDOW~1\
v1.0\;C:\Windows\idmu\common;C:\myprograms\ZANTAZ\EASOUT~1.2\bin;C:\PROGRA~2\MIE3C7~1;C:\Windows\System32\WINDOW~1\v1.0\;C:\PROGRA~1\TORTOI~1\bin;C:\myprograms\APACHE~2.3\bin;C:\TD\TD_RF_~1.0\gnu\bin;C:\myprograms\WLSTAP~1.2\bin;C:\myprograms\PHANTO~1.0-W;C:\myprograms\RUBY-2~1.2-X\bin;C:\myprograms\RUBY-2~1.3-X;C:\PROGRA~2\Java\JDK17~1.0_7\bin;C:\PROGRA~2\QUICKT~1\QTSystem\;C:\myprograms\Tools\wls12130\wlserver\server\native\win\32\oci920_8
.
***************************************************
*  To start WebLogic Server, …
Run Code Online (Sandbox Code Playgroud)

java weblogic12c

14
推荐指数
1
解决办法
2万
查看次数

在JPA中选择具有1个条件的每个用户的最近日期的行

我有这个实体,我想为每个设备列出属性message = 1的最后一个事件

@Entity
@Table(name = "t_device_event")
@NamedQueries(value = { 
@NamedQuery(name = "DeviceEvent.findWithMessageActive",
            query = "from DeviceEvent as de1 where de1.message = 1 and de1.received = " 
                  + " ( select max(de2.received) from DeviceEvent de2 " 
                  + " where de2.device.id = de1.device.id )  "), )
public class DeviceEvent {
     ..
}
Run Code Online (Sandbox Code Playgroud)

但是在最后一次测试中我有一个断言问题,因为它认为device3是最后一个事件,而不是这种情况.

assertTrue ((numDevicesWithActiveMessage+1) == deviceEventService.findWithActiveMessage().size());

DeviceEvent deviceEvent3 = newDeviceEvent();
deviceEvent3.setMessage(1);
deviceEventService.save(deviceEvent3);

DeviceEvent deviceEvent4 = newDeviceEvent();
deviceEventService.save(deviceEvent4);

assertTrue ((numDevicesWithActiveMessage+1) == deviceEventService.findWithActiveMessage().size());
Run Code Online (Sandbox Code Playgroud)

java sql junit mysqli jpa

13
推荐指数
1
解决办法
539
查看次数

@RolesAllowed vs. @PreAuthorize vs. @Secured

我有一个基本的SpringBoot应用程序.使用Spring Initializer,嵌入式Tomcat,Thymeleaf模板引擎和包作为可执行的JAR文件.

我想保护一个控制器:

@Controller
@RequestMapping("/company")
@RolesAllowed({"ROLE_ADMIN"})
@PreAuthorize("hasRole('ADMIN')")
@Secured("ADMIN")
public class CompanyController {
}
Run Code Online (Sandbox Code Playgroud)

我知道有不同的选择,但我真的不知道应该使用哪种

spring spring-mvc spring-security spring-boot

13
推荐指数
3
解决办法
3885
查看次数

OpenLayers:从服务器获取 Map、View、TileLayer 和 OSM

我是 OpenLayers(一个开源 JavaScript 库,用于在 Web 浏览器中将地图数据显示为滑动地图)的新手。我将它与 Thymeleaf(一个 Java XML/XHTML/HTML5 模板引擎,可以在 Web 和非 Web 环境中工作)一起使用。

我正在尝试重现此示例,但从服务器获取资源https://openlayers.org/en/latest/examples/reprojection-wgs84.html

我有这个页面:

<!doctype html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <title>Title</title>
    <script src="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/v6.3.1/build/ol.js"></script>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/v6.3.1/css/ol.css">

    <style>
        .map {
            width: 100%;
            height:400px;
        }
    </style>
</head>
<body>

<div id="layout">


    <div id="main">

        <div class="content">
            <div class="pure-g">

                <div class="pure-u-1-1 pure-u-xl-10-24 pure-u-med-1">

                    <!-- Content right Wrap -->
                    <div class="content_r_wrap">

                        <!-- Devices Map Module -->
                        <div class="windowHead">
                            <h2>LOCATION INFO</h2>
                        </div>
                        <div class="windowContentMap">
                            <div id="map" class="map"></div>
                                <script th:inline="javascript" th:type="module">
                                  /*<![CDATA[*/
                                  import Map from …
Run Code Online (Sandbox Code Playgroud)

html javascript css openlayers thymeleaf

11
推荐指数
1
解决办法
334
查看次数