小编Doc*_*ter的帖子

text-align:center不使用div元素

我一直在寻找大约45分钟,但在这里找不到我的问题的解决方案.我想要我的gallery类div(这些将动态创建)以仅使用css规则将它们自动对齐gallery_container div的中心.我正在学习,所以任何解释都会有所帮助!

提前致谢!

<head>
    <style>
    #gallery_container{
        text-align: center; 
        width:100%;
        overflow: auto; 
        background:orange;  
    }
    .gallery{
        text-align: left;   
        border-style: solid;
        border-width:3px;
        border-top-left-radius: 40px;
        border-bottom-right-radius: 40px; 
        background:yellow;
        width:335px;
        padding:20px;
        float:left;
        margin:15px;
    }
    .gallery h2{
        margin-top:0;
    }
    .gallery img{
        height:120px;
        width:160px;
        float:right;
    }
</style>

<body>
    <div id ='content_gallery'>
        <h2>Gallery</h2>

        <div id='gallery_container'>
            <div class = gallery>
                <img src = 'bowling_01.png'>
                <h2>Company bowling</h2>
                <h4>Date: June 14, 2013</h4>
                <p>The company heads to Boca Bowl for our monthly bowling event!</p>
            </div>

            <div class = gallery>
                <img src = …
Run Code Online (Sandbox Code Playgroud)

html layout text-align center

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

@Autowired对象仅在测试时为空

我的问题与应用程序设置有关,而不是嘲笑或使用自动装配.有关详细信息,请参阅答案.

我正在尝试设置一个Spring Boot应用程序,但是我在创建单元测试时遇到了问题.我的问题是,我所拥有的所有对象@Autowired仅在单元测试期间为空.当我正常运行应用程序时,我可以使用CURL,它可以工作.但是当我用JUnit测试时,当我尝试使用这些@Autowired对象时,我得到一个空指针.我没有使用xml文件来配置我的bean,也许这是我的问题?

Application.java

package com.blakeparmeter.metricsapi;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
 *
 * @author Blake
 */
@SpringBootApplication
@EnableAutoConfiguration
public class Application {

    public static void main(String[] args){
        SpringApplication.run(Application.class, args);
    }
}
Run Code Online (Sandbox Code Playgroud)

MetricApi.java

package com.blakeparmeter.metricsapi.api;

import com.blakeparmeter.metricsapi.beans.Metric;
import com.blakeparmeter.metricsapi.controllers.MetricController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Handles all the REST responses logic of the Metrics services. 
 * Complex logic should be moved outside of this class.
 * @author …
Run Code Online (Sandbox Code Playgroud)

java junit autowired spring-boot

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

标签 统计

autowired ×1

center ×1

html ×1

java ×1

junit ×1

layout ×1

spring-boot ×1

text-align ×1