小编Jak*_*ała的帖子

在Spring Boot中的application.properties中使用Maven属性

我正在尝试将属性从pom.xml加载到application.properties中.我想创建两个配置文件:dev和prod以使用不同的数据库URL.我在我的所有应用程序中使用Jenkins作为CI(主要是Spring MVC,没有Boot项目)正在使用maven配置文件部署到Tomcat.使用maven属性有可能做到这一点吗?我试过这样的事情: spring.datasource.url=${jdbc.url}

spring maven spring-boot spring-boot-maven-plugin

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

视图未附加到窗口管理器,对话框关闭

所以我调用了活动GameActivity.java,在这个活动中我称之为DialogAnswer.show()简单显示屏幕上的一些图片.

java.lang.IllegalArgumentException: View not attached to window manager
at android.view.WindowManagerGlobal.findViewLocked(WindowManagerGlobal.java:402)
at android.view.WindowManagerGlobal.removeView(WindowManagerGlobal.java:304)
at android.view.WindowManagerImpl.removeView(WindowManagerImpl.java:79)
at android.app.Dialog.dismissDialog(Dialog.java:325)
at android.app.Dialog.dismiss(Dialog.java:307)
at pl.evelanblog.prawdaczyfalsz.screen.DialogAnswer$1.onFinish(DialogAnswer.java:36)
at android.os.CountDownTimer$1.handleMessage(CountDownTimer.java:118)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5328)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(Native Method)
Run Code Online (Sandbox Code Playgroud)

这是我的DialogAnswer.java班级

public class DialogAnswer extends Activity {

   private static ImageView resultImage;
   private static Dialog dialog = null;

   public static void show(Context context, boolean fCorrect) {

       dialog = new Dialog(context, android.R.style.Theme_Translucent_NoTitleBar_Fullscreen);
       dialog.setContentView(R.layout.dialog);
       resultImage = (ImageView) …
Run Code Online (Sandbox Code Playgroud)

android

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

如何处理倒计时计时器

我有一个名为“MainActivity”的主类,我在我的应用程序中多次使用它。

private static CountDownTimer timer;
private static final long startTime = 15 * 1000;
private static final long interval = 1 * 1000;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    timer = new StageCountDownTimer(startTime, interval);

}

private class StageCountDownTimer extends CountDownTimer {
    public StageCountDownTimer(long startTime, long interval) {
        super(startTime, interval);
    }

    @Override
    public void onFinish() {
        //STARTTING NEW ACTIVITY 
    }

    @Override
    public void onTick(long millisUntilFinished) {
    }
}
Run Code Online (Sandbox Code Playgroud)

有时用户需要在倒计时结束前关闭此活动,然后再次返回此活动。然后新的倒计时开始,但旧的onFinish()倒计时结束时执行代码。当我启动此代码一次时,一切都很好。退出活动后如何取消/处置/销毁此计时器?我试过了timer.cancel(),没有任何反应。

编辑

我想我通过将 CountDownTimer 计时器设置为公共和其他活动来解决我的问题,我只是使用 MainActivity.timer.cancel()

android countdowntimer

5
推荐指数
1
解决办法
3052
查看次数

Thymeleaf 布局方言 - Java 配置

我将 Thymeleaf 从 2.1 版本升级到 3.0 BETA-1。新的 Thymeleaf 需要 java 配置,所以我将 xml 配置重写为 java。一切正常,期待布局方言。我不明白为什么。

@Configuration
@EnableWebMvc
@ComponentScan
public class ThymeleafConfig extends WebMvcConfigurerAdapter implements ApplicationContextAware {

    private ApplicationContext applicationContext;

    public void setApplicationContext(ApplicationContext applicationContext) {
        this.applicationContext = applicationContext;
    }


    @Override
    public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
        configurer.enable();
    }

    @Bean(name = "templateViewResolver")
    public ViewResolver viewResolver() {
        ThymeleafViewResolver resolver = new ThymeleafViewResolver();
        resolver.setTemplateEngine(templateEngine());
        resolver.setCharacterEncoding("UTF-8");
        resolver.setContentType("text/html; charset=UTF-8");
        return resolver;
    }

    @Bean(name = "templateEngine")
    public TemplateEngine templateEngine() {
        TemplateEngine engine = new TemplateEngine();
        engine.setTemplateResolver(templateResolver());
        engine.addDialect(new SpringSecurityDialect());
        engine.addDialect(new …
Run Code Online (Sandbox Code Playgroud)

java spring thymeleaf

5
推荐指数
1
解决办法
3464
查看次数

将不同尺寸的图像调整为特定格式

我正在解析来自不同API的图像,我想在网站上显示它.但我有问题,以特定的大小显示它以适应它在引导程序列表(~700x300px)有时图像是纵向而不是横向.整个700x300px空间应该由图像填充,但不能拉伸.

方法#1将 图像下载到服务器,调整大小并进行转换.来自localserver的主机而不是远程链接.

方法#2 使用AngularJS的一些魔法(我是那个区域的新手)

方法#3 使用CSS/HTML5的一些魔力(我也是新手)

现在我得到了这样的东西

<style>
    .list {
        width: 700px;
        height: 250px;
        overflow: hidden;
        position: relative;
    }

    div img {
        position: absolute;
    }
</style>
Run Code Online (Sandbox Code Playgroud)

http://i.imgur.com/mdjEWKX.png

html css html5 twitter-bootstrap angularjs

5
推荐指数
1
解决办法
55
查看次数

将QueryDSL与MongoDB一起使用 - java.lang.NoClassDefFoundError

我正在尝试将QueryDSL与MongoDB集成(由Spring Data提供)我也在使用JPA存储库,因此我在模块模块和存储库模块中分离了包.Spring Data依赖项来自Spring Data Realease Train版本Hopper-SR1.查询DSL版本3.7.2.

        <!-- Spring Data -->
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-mongodb</artifactId>
        </dependency>

        <!-- Query DSL-->
        <dependency>
            <groupId>com.mysema.querydsl</groupId>
            <artifactId>querydsl-apt</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.mysema.querydsl</groupId>
            <artifactId>querydsl-mongodb</artifactId>
        </dependency>
        <dependency>
            <groupId>com.mysema.querydsl</groupId>
            <artifactId>querydsl-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>com.mysema.querydsl</groupId>
            <artifactId>querydsl-core</artifactId>
        </dependency>
Run Code Online (Sandbox Code Playgroud)

我的插件confuguration

<build>
    <plugins>
        <plugin>
            <groupId>com.mysema.maven</groupId>
            <artifactId>apt-maven-plugin</artifactId>
            <version>1.1.3</version>
            <executions>

                <!-- JPA Query DSL -->
                <execution>
                    <id>jpa</id>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>process</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>target/generated-sources/java</outputDirectory>
                        <processor>com.mysema.query.apt.jpa.JPAAnnotationProcessor</processor>
                    </configuration>
                </execution>

                <!-- Mongo Query DSL -->
                <execution>
                    <id>mongo</id>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>process</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>target/generated-sources/java</outputDirectory>
                        <processor>org.springframework.data.mongodb.repository.support.MongoAnnotationProcessor …
Run Code Online (Sandbox Code Playgroud)

java maven querydsl spring-data

5
推荐指数
2
解决办法
3075
查看次数

多个小部件大小

我在网上搜索但没有任何帮助.我想制作第二个小部件,只是更大.我使用服务来更新我的小部件所以我需要创建2个服务(通过远程视图等更新小部件中的数据)或者我可以更容易吗?

当我添加媒体小部件时,它显示小的一个,但它需要更多的空间(144dp x 72dp),并且没有更新.也许我应该复制整个应用程序类并修改它,但我认为这是一个愚蠢的解决方案.

我正在尝试这个解决方案

如何在一个应用程序中添加多个小部件?

如何在一个apk中放置多个小部件大小?

任何提示?:)

android android-widget android-layout android-appwidget

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

关闭插页式广告后,应用会关闭

根据文档:https://developers.google.com/mobile-ads-sdk/docs/admob/advanced

我要求活动,

interstitial.loadAd(adRequest);
interstitial.setAdListener(this);
Run Code Online (Sandbox Code Playgroud)

并在回调中收到它时显示插页式广告

 @Override
  public void onReceiveAd(Ad ad) {
    Log.d("OK", "Received ad");
    if (ad == interstitial) {
      interstitial.show();
    }
  }
Run Code Online (Sandbox Code Playgroud)

但是我有很多评论,关于广告何时被用户关闭,应用程序关闭,他们必须重新开始.我不是finish()在使用onResumeonStop仅在onBackPressed.此外我在这个活动中使用Facebook SDK并且有onActivityResult.当我在Motorola RAZR和Nexus 7上测试我的应用程序时一切正常.

android admob

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

Nginx子域不起作用

我不知道怎么了 我在日志中没有收到任何警告。我有与此类似的配置 如何在nginx配置中排除特定的子域server_name

我想创建子域us.example.io我正在ping检查它

ping us.example.io
ping: cannot resolve us.example.io: Unknown host
Run Code Online (Sandbox Code Playgroud)

nginx.config

 server {
    server_name *. us.example.io us.example.io;
    listen 80;
    root /usr/share/nginx/html/bint;
    index index.html index.htm index.php;
    location / {
      try_files $uri $uri/ /index.html;   
    }
  }

  server {
    server_name us.example.io;
    listen 80;
    return http://www.google.com;
  }
Run Code Online (Sandbox Code Playgroud)

nginx

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

从JSON字符串获取数据

我无法从下面的JSON字符串中成功获取数据.使用JavaScript,我能够提醒完整的字符串[alert(data); ]但我无法得到第一个名字.

有人可以帮忙吗?

var data = {
    "name": [
        "Enid Norgard",
        "Cassie Durrett",
        "Josephine Ervin"
    ],
    "email": [
        "TheWoozyGamer@gmail.com",
        "TheHabitualGamer@gmail.com",
        "TheUptightGamer@gmail.com"
    ],
    "role": [
        "Gamer",
        "Team Leader",
        "Player"
    ],
    "emp_id": [
        "50",
        "408",
        "520"
    ],
    "id": [
        "234",
        "444",
        "235"
    ]
}
Run Code Online (Sandbox Code Playgroud)

javascript jquery json

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

如何获得独特的随机int?

static int n = -1;  
private static int repeatBuffer[] = new int[10];
static {
    repeatBuffer[0] = 0;
    //and more
    repeatBuffer[9] = 9;
}
static public void randomize() {

    do {
        Random r = new Random();
        randomNumber = r.nextInt(20);
    } while (!uniqueInt(randomNumber));
    Log.e(TAG, "" + randomNumber); //here I need have a unique int
}

private static Boolean uniqueInt(int random) {

    for (int i = 0; i < 9; i++) {
        if (random == repeatBuffer[i]) {
            return false;
        }
    }
    if (++n …
Run Code Online (Sandbox Code Playgroud)

java random android unique

0
推荐指数
1
解决办法
149
查看次数

如何检查字符串数组中的元素是否为空?

如何检查字符串数组中的元素是否为空?这是我的示例数组:

private static String correct[] = new String[5];
    static {
        correct[1] = "some texT";
        correct[2] = "some texT3";
        correct[4] = "some texT2";
}
Run Code Online (Sandbox Code Playgroud)

我可以分配null其余的元素,但我想找到另一个更好的方法来做到这一点.我找到了isEmpty,但它仅适用于API 9及更高版本.

if(correct[0].length() > 0) 给我一个NPE. if(correct[0] != null也.

java

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