小编Rea*_*tic的帖子

maven更新后,Java版本自动更改为java 1.5

我使用eclipse作为IDE.当我右键单击项目然后单击maven更新我的java版本更改为1.5.这是我到目前为止所做的,我按照这里列出的所有步骤

http://qussay.com/2013/09/13/solving-dynamic-web-module-3-0-requires-java-1-6-or-newer-in-maven-projects/

  1. 我将"Java构建路径"更改为"工作区默认jre 1.8.0_25"
  2. 然后将"java compiler"更改为1.8
  3. 然后改变了"project facets"> java> 1.8
  4. 将pom.xml java版本更改为1.8
    <build>
        <plugins>
            <plugin>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
                <version>9.1.3.v20140225</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugin</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
Run Code Online (Sandbox Code Playgroud)

毕竟当我点击"Maven update"时,我的java版本会自动更改为1.5.同样在上述步骤中,前两步的版本也会自动更改为1.5.我怎样才能解决这个问题?

java eclipse maven

106
推荐指数
4
解决办法
7万
查看次数

如何根据方向元数据旋转JPEG图像?

我有一些服务器代码在上传图像时生成缩略图.问题在于,当拍摄图像并旋转相机/设备时,即使在任何图像查看软件中以正确的方向显示全尺寸图像本身,也会旋转缩略图.这只发生在jpgs上.

在OSX上使用Preview,我可以看到jpgs中嵌入了方向元数据.当我使用ImageTools(Grails插件)生成缩略图时,EXIF元数据不在缩略图中,这就是缩略图显示为旋转的原因.

通过离线对话,我了解到虽然读取EXIF元数据相对容易,但没有简单的方法来编写它,这就是生成jpg缩略图时数据丢失的原因.

所以看来我有两个选择:

  1. 使用ImageMagick生成缩略图.缺点是它需要在我们的服务器上安装更多软件.
  2. 阅读EXIF Orientation数据是代码并适当旋转缩略图.

有没有人知道其他任何选择?

java groovy image-processing

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

如何在长的特定位置设置/取消位?

如何在Java中的long的特定位置设置/取消位?

例如,

long l = 0b001100L ; // bit representation
Run Code Online (Sandbox Code Playgroud)

我想在位置2处设置位并在位置3处取消设置位,因此相应的长度将是,

long l = 0b001010L ; // bit representation
Run Code Online (Sandbox Code Playgroud)

任何人都可以帮我怎么做?

java bit-manipulation bitwise-operators

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

在变量和方法名称中使用下划线

我对变量名和方法名中使用下划线(命名约定)_作为起始字母感到困惑.例如_sampleVariable_getUserContext().任何人都可以澄清何时使用它?

java variables naming-conventions

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

在Stream reduce方法中,对于sum,标识总是0,对于乘法,1必须是1?

我继续学习java 8.

我发现了有趣的行为:

让我们看看代码示例:

// identity value and accumulator and combiner
        Integer summaryAge = Person.getPersons().stream()
                //.parallel()  //will return surprising result
                .reduce(1, (intermediateResult, p) -> intermediateResult + p.age,
                        (ir1, ir2) -> ir1 + ir2);
        System.out.println(summaryAge);
Run Code Online (Sandbox Code Playgroud)

和模型类:

public class Person {

    String name;

    Integer age;
    ///...

    public static Collection<Person> getPersons() {
        List<Person> persons = new ArrayList<>();
        persons.add(new Person("Vasya", 12));
        persons.add(new Person("Petya", 32));
        persons.add(new Person("Serj", 10));
        persons.add(new Person("Onotole", 18));
        return persons;
   }
}
Run Code Online (Sandbox Code Playgroud)

12 + 32 + 10 + 18 = 72
对于序列流,此代码始终返回73(72 …

java reduce java-8 java-stream

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

Android:没有"/"的改进URL路径

所以我实际上是在尝试使用TypedByteArray作为我的身体进行PUT.我正在与Azure服务器进行交互,因此第一步是

  1. 使用我的图像元数据进行POST调用,然后返回一个URL(例如URL_PUT)

  2. 我必须向该URL_PUT发出PUT请求(从步骤1开始),所以我的改进单例接口函数如下所示:

    public interface ImageInterface {

         @PUT("/{nothing}")
         Response uploadBlob(@Body TypedByteArray byteArray, 
             @Header("Content-Length") String byteArrayLength, 
             @Path(value="nothing",encode=false) String nothing);

    }
Run Code Online (Sandbox Code Playgroud)

但我得到一个错误,说当我通过""时,URL路径必须以"/"开头.对于上面的函数我尝试传递一个空字符串,但无济于事.

所以基本上我只想使用端点进行改造,但PUT没有路径/ balnk路径.有没有办法做到这一点?

android http retrofit

9
推荐指数
1
解决办法
1478
查看次数

为什么在离开泛型运算符时不推断类型

我读到自Java 7以来,在第一个语句中创建右侧指定类型的集合是不好的样式,因为编译器可以从左侧推断出类型.

List<Integer> myList = new ArrayList<Integer>();
Run Code Online (Sandbox Code Playgroud)

我的问题是,当像这样初始化列表时,编译器找不到类型,我得到一个未经检查的类型警告:

List<Integer> myList = new ArrayList(); 
Run Code Online (Sandbox Code Playgroud)

java generics

9
推荐指数
3
解决办法
675
查看次数

如何通过 Python 访问数位板笔数据?

我需要通过Python访问Windows平板电脑笔数据(例如表面)。我主要需要位置、压力和倾斜值。

我知道如何访问 Wacom 笔数据,但 Windows 笔不同。

有一个名为Kivy的 Python 库的 Python 库可以处理多点触控,但它会将我的笔识别为手指 (WM_TOUCH),而不是笔 (WM_PEN)。

这是我的 Kivy 代码(不报告压力和倾斜):

 from kivy.app import App
 from kivy.uix.widget import Widget

class TouchInput(Widget):

def on_touch_down(self, touch):
    print(touch)
def on_touch_move(self, touch):
    print(touch)
def on_touch_up(self, touch):
    print("RELEASED!",touch)

class SimpleKivy4(App):

def build(self):
    return TouchInput()
Run Code Online (Sandbox Code Playgroud)

有一个名为Tablet 的出色处理库,它仅适用于具有简单 API 的 Wacom 数位板(例如,tablet.getPressure()

我需要这样的东西。

python surface tablet stylus-pen

8
推荐指数
1
解决办法
4673
查看次数

我得到一个异常:java.lang.IllegalStateException:已经为此响应调用了getOutputStream()

我想编写代码来下载一个存储在我系统中的文件

这是我的代码:

在控制器类中,我有以下映射

@RequestMapping(value = "/processFile", method = RequestMethod.POST)
    public @ResponseBody ModelAndView downloadFileProcess(
            @RequestParam("file") File originalFile,
            @RequestParam("action") String action, HttpServletResponse response) {

        ModelAndView model = new ModelAndView();
        model.setViewName("error");
        System.out.println("");
        System.out.println("Action: "+action);
        model.addObject("message", "Action:" + action);
        try {
            utility.downloadFile(originalFile, response);
            message = "The file was downloaded successfully";

        } catch (IOException e) {
            e.printStackTrace();
            message = "The process failed due to following reason: "
                    + e.getMessage();
        } catch (Exception e) {
            e.printStackTrace();
            message = "The process failed due to following reason: " …
Run Code Online (Sandbox Code Playgroud)

java spring-mvc spring-boot

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

我可以使构造函数通用而不使类通用吗?

我在Java中看到,可以创建一个Class泛型和一个泛型方法.我还看到了使构造函数与Class一起通用的代码.我可以只使构造函数通用吗?如果是,如何调用构造函数?

java

6
推荐指数
1
解决办法
92
查看次数