问:
ASP.NET listview changing selected row color
What I want to do is: when I click on the 'view' button, the selected row should be highlighted.

I have googled for few hours but can't really understand what I missed:

```<code><tr height="30%">
    <td valign="top">
        <div runat="server" id="area" style="height:300px; overflow:scroll">
            <asp:Label ID="lbl_Result" runat="server"></asp:Label>
            <asp:ListView ID="lv_MessageSubject" runat="server" vertical-align="top" OnSelectedIndexChanged="lv_MessageSubject_SelectedIndexChanged" OnSelectedIndexChanging="lv_MessageSubject_SelectedIndexChanging" DataKeyNames ="MessageID" OnPagePropertiesChanged="lv_MessageSubject_PagePropertiesChanged" OnPagePropertiesChanging="lv_MessageSubject_PagePropertiesChanging" OnItemDataBound="lv_MessageSubject_ItemDataBound">
            <LayoutTemplate>
            <table border="1">
                <tr runat="server">
                    <th runat="server"></th>
                    <th runat="server">Message</th>
                    <th runat="server">Sender</th>
                </tr>
                <tr runat="server" id="itemPlaceholder" />
            </table>
        </LayoutTemplate>
        <ItemTemplate>
            <tr>
            <td><asp:Button ID="cmd_View" runat="server" CommandName="Select" Text="View" Height="21px" /></td>
            <td><div runat="server" id="area"><asp:Label ID="Label2" runat="server" Text='<%#Eval("Message") %>' /></div></td>
            <td><asp:Label ID="Label3" runat="server" Text='<%#Eval("Sender") %>' /></td>
            </tr>
        </ItemTemplate>
        </asp:ListView>
        <asp:DataPager ID="DataPager" runat="server" PagedControlID="lv_MessageSubject"
            PageSize="10">
            <Fields>
                <asp:NextPreviousPagerField ShowFirstPageButton="True" ShowNextPageButton="False" />
                <asp:NumericPagerField />
                <asp:NextPreviousPagerField ShowLastPageButton="True" ShowPreviousPageButton="False" />
            </Fields>
        </asp:DataPager>
        </div>
        </td>
    </tr>
</code>```

I was told to use ItemDataBound, even though I don't know how the selected change can trigger ItemDataBound. Here is the code I tried anyway:

```<code>protected void lv_MessageSubject_ItemDataBound(object sender, ListViewItemEventArgs e)
    {
        if (((ListView)sender).SelectedIndex == e.Item.DisplayIndex)
        {
            var ctrl = (HtmlContainerControl)e.Item.FindControl("area");
            ctrl.Attributes["style"] = "background-color:Navy; color:White; padding:0px;";
        }
    }
</code>```

The result is ItemDataBound didn't trigger when I click on the 'view' button.

答:
ItemDataBound does not sounds like a right idea indeed. Since your button is setup to fire a command, ItemCommand looks more appropriate:

```<code><asp:ListView ... OnItemCommand="lv_MessageSubject_ItemCommand"

...

<asp:Button ID="cmd_View" runat="server" CommandName="Highlight"

...

protected void lv_MessageSubject_ItemCommand(Object sender, ListViewCommandEventArgs e)
{
    if (e.CommandName == "Highlight")
    {
        var ctrl = (HtmlContainerControl)e.Item.FindControl("area");
        ctrl.Attributes["style"] = "background-color:Navy; color:White; padding:0px;";
    }
}
</code>```

Note that event has a different name - "Select" is special in a sense that it invokes some built-in functionality, you probably should not interfere with that.

Body:
What I want to do is: when I click on the 'view' button, the selected row should be highlighted.

I have googled for few hours but can't really understand what I missed:

            <asp:Label ID="lbl_Result" runat="server"></asp:Label>
            <asp:ListView ID="lv_MessageSubject" runat="server" vertical-align="top" OnSelectedIndexChanged="lv_MessageSubject_SelectedIndexChanged" OnSelectedIndexChanging="lv_MessageSubject_SelectedIndexChanging" DataKeyNames ="MessageID" OnPagePropertiesChanged="lv_MessageSubject_PagePropertiesChanged" OnPagePropertiesChanging="lv_MessageSubject_PagePropertiesChanging" OnItemDataBound="lv_MessageSubject_ItemDataBound">
            <LayoutTemplate>

                    Message
                    Sender

        </LayoutTemplate>
        <ItemTemplate>

            <asp:Button ID="cmd_View" runat="server" CommandName="Select" Text="View" Height="21px" />

<asp:Label ID="Label2" runat="server" Text='<%#Eval("Message") %>' />

            <asp:Label ID="Label3" runat="server" Text='<%#Eval("Sender") %>' />

        </ItemTemplate>
        </asp:ListView>
        <asp:DataPager ID="DataPager" runat="server" PagedControlID="lv_MessageSubject"
            PageSize="10">
            <Fields>
                <asp:NextPreviousPagerField ShowFirstPageButton="True" ShowNextPageButton="False" />
                <asp:NumericPagerField />
                <asp:NextPreviousPagerField ShowLastPageButton="True" ShowPreviousPageButton="False" />
            </Fields>
        </asp:DataPager>

I was told to use ItemDataBound, even though I don't know how the selected change can trigger ItemDataBound. Here is the code I tried anyway:

protected void lv_MessageSubject_ItemDataBound(object sender, ListViewItemEventArgs e)
    {
        if (((ListView)sender).SelectedIndex == e.Item.DisplayIndex)
        {
            var ctrl = (HtmlContainerControl)e.Item.FindControl("area");
            ctrl.Attributes["style"] = "background-color:Navy; color:White; padding:0px;";
        }
    }

The result is ItemDataBound didn't trigger when I click on the 'view' button.

Body:
ItemDataBound does not sounds like a right idea indeed. Since your button is setup to fire a command, ItemCommand looks more appropriate:

<asp:ListView ... OnItemCommand="lv_MessageSubject_ItemCommand"

...

<asp:Button ID="cmd_View" runat="server" CommandName="Highlight"

...

protected void lv_MessageSubject_ItemCommand(Object sender, ListViewCommandEventArgs e)
{
    if (e.CommandName == "Highlight")
    {
        var ctrl = (HtmlContainerControl)e.Item.FindControl("area");
        ctrl.Attributes["style"] = "background-color:Navy; color:White; padding:0px;";
    }
}

Note that event has a different name - "Select" is special in a sense that it invokes some built-in functionality, you probably should not interfere with that.


来源: stackexchange

问:
How to detect app server embedded or standalone?
Is it possible to detect if a spring-boot application is running on an  embedded tomcat or on a standalone tomcat server?

I want to create a @Configuration that only executes on a standalone server.
But I don't want to use@Profile for this because all profiles should as well be executable inside an embedded tomcat during dev.

The following does not work so far:

```<code>@Configuration
@AutoConfigureAfter(EmbeddedServletContainerAutoConfiguration.class)
@ConditionalOnMissingBean(EmbeddedServletContainerFactory.class)
@ConditionalOnMissingBean(TomcatEmbeddedServletContainerFactory.class)
public class TomcatConfig {
        @ConditionalOnMissingBean(EmbeddedServletContainerFactory.class)
        @ConditionalOnMissingBean(TomcatEmbeddedServletContainerFactory.class)
        @Bean
        public MyBean init() {
                  //this should not execute in embedded tomcat
        }
}

@Configuration
public class MainConfig extends SpringBootServletInitializer {
    public static void main(String[] args) {
        SpringApplication.run(MainConfig.class, args);
    }

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

}
</code>```

答: Untested, but you can probably just check for @ConditionalOnMissingBean(TomcatEmbeddedServletContainerFactory.class)

ContentLicense: CC BY-SA 3.0

Body:
Is it possible to detect if a spring-boot application is running on an  embedded tomcat or on a standalone tomcat server?

I want to create a @Configuration that only executes on a standalone server.
But I don't want to use@Profile for this because all profiles should as well be executable inside an embedded tomcat during dev.

The following does not work so far:

@Configuration
@AutoConfigureAfter(EmbeddedServletContainerAutoConfiguration.class)
@ConditionalOnMissingBean(EmbeddedServletContainerFactory.class)
@ConditionalOnMissingBean(TomcatEmbeddedServletContainerFactory.class)
public class TomcatConfig {
        @ConditionalOnMissingBean(EmbeddedServletContainerFactory.class)
        @ConditionalOnMissingBean(TomcatEmbeddedServletContainerFactory.class)
        @Bean
        public MyBean init() {
                  //this should not execute in embedded tomcat
        }
}

@Configuration
public class MainConfig extends SpringBootServletInitializer {
    public static void main(String[] args) {
        SpringApplication.run(MainConfig.class, args);
    }

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

}


问:
rxjs call combineLatest in combineLatest
I got a problem with rxjs and with combineLatest method.
I am trying to call combineLatest in combineLatest and it doesn't work, although it returns Observable object. Help to resolve the problem, please. console.log is never called

Actually, all the observers in the different files, so I can't move this.search$ to this.services$

```<code>this.search$ = store.select('search');

this.services$ = Observable.combineLatest(
    store.select('currentRegions'),
    store.select('services'),
    (regions, services) => {
        // some filter here
        return services;
    }
);

this.autocomplete$ = Observable.combineLatest(
    this.search$,
    this.services$,
    (search, services) => {
        console.log('show me, please');
        return '';
    }
);
</code>```

Resolved: It doesn't work without any subscriber, so I had to subscribe it

答:
RxJS CombineLatest is kind of AngularJS $q.all </p>

```<code>import 'rxjs/add/observable/combineLatest';

Observable
      .combineLatest(this.store.select('currentRegions'), this.store.select('services')
      .do(console.log)
      .subscribe();
</code>```

Body:
I got a problem with rxjs and with combineLatest method.
I am trying to call combineLatest in combineLatest and it doesn't work, although it returns Observable object. Help to resolve the problem, please. console.log is never called

Actually, all the observers in the different files, so I can't move this.search$ to this.services$

this.search$ = store.select('search');

this.services$ = Observable.combineLatest(
    store.select('currentRegions'),
    store.select('services'),
    (regions, services) => {
        // some filter here
        return services;
    }
);

this.autocomplete$ = Observable.combineLatest(
    this.search$,
    this.services$,
    (search, services) => {
        console.log('show me, please');
        return '';
    }
);

Resolved: It doesn't work without any subscriber, so I had to subscribe it

Body:
RxJS CombineLatest is kind of AngularJS $q.all

import 'rxjs/add/observable/combineLatest';

Observable
      .combineLatest(this.store.select('currentRegions'), this.store.select('services')
      .do(console.log)
      .subscribe();


问:
Migrating Projects from Mac OS to Windows
I was using Mac OS for developing my android projects. And now Im moving to Windows System,so I wanted to migrate all my earlier android studio projects into my windows system environment.
Anybody please help me to how to move all the android projects to windows at once...

Thanks in advance

答: Android projects (if you use Android Studio) are Gradle project, so there is no need to do any config at all, you just have to copy them from mac OS and import them into Android Studio using Windows and they will work just fine. Even if you open them using Android Studio it will propose you to fix the local properties but I would suggest to import them instead.</p>


问:
Need progress bar at the time of unzip in SWT wizard by java
I have implement SWT wizard appliation, In this application i performed unzip file programatically and i need a progress bar during unzip. Please find the below code for unzip,

```<code> public static void extract(File zipfile, File outdir)
      {
        try
        {
          ZipInputStream zin = new ZipInputStream(new FileInputStream (zipfile));
          ZipEntry entry;
          String name, dir;
          while ((entry = zin.getNextEntry()) != null)
          {
            name = entry.getName();
            if( entry.isDirectory() )
            {
              mkdirs(outdir,name);
              continue;
            }
            /* this part is necessary because file entry can come before
             * directory entry where is file located
             * i.e.:
             *   /foo/foo.txt
             *   /foo/
             */
            dir = dirpart(name);
            if( dir != null )
              mkdirs(outdir,dir);

            extractFile(zin, outdir, name);

          }

          zin.close();
        }
        catch (IOException e)
        {
          e.printStackTrace();
        }
      }
</code>```

At the wizard page i call this method like this,

```<code>    btnUnzip.addListener(SWT.Selection, new Listener() {

            @Override
            public void handleEvent(Event event) {

                    File file = new File(text.getText());
                    File file1 = new File(textToSaveUnzipFile.getText());
                    UnzipUtility.extract(file, file1);
      }
   }
</code>```

答:
If you are using a JFace Wizard you can use the built in progress monitor in the wizard.

In the Constructor of your Wizard class call:

```<code>setNeedsProgressMonitor(true);
</code>```

To show progress call

```<code>getContainer().run(true, true, runnable);
</code>```

This call can be in the Wizard or a WizardPage.

where runnable is a class implementing IRunnableWithProgress. The run method of this class will look something like:

```<code>@Override
public void run(final IProgressMonitor monitor)
  throws InterruptedException
{
  monitor.beginTask("Title", .. number of work steps ..);

  try
   {
     while (not finished) {
        ... do a small amount of work

        // Update progress
        monitor.worked(1);
     }
   }
  finally
   {
     monitor.done();
   }
}
</code>```

Body:
I have implement SWT wizard appliation, In this application i performed unzip file programatically and i need a progress bar during unzip. Please find the below code for unzip,

 public static void extract(File zipfile, File outdir)
      {
        try
        {
          ZipInputStream zin = new ZipInputStream(new FileInputStream (zipfile));
          ZipEntry entry;
          String name, dir;
          while ((entry = zin.getNextEntry()) != null)
          {
            name = entry.getName();
            if( entry.isDirectory() )
            {
              mkdirs(outdir,name);
              continue;
            }
            /* this part is necessary because file entry can come before
             * directory entry where is file located
             * i.e.:
             *   /foo/foo.txt
             *   /foo/
             */
            dir = dirpart(name);
            if( dir != null )
              mkdirs(outdir,dir);

            extractFile(zin, outdir, name);

          }

          zin.close();
        }
        catch (IOException e)
        {
          e.printStackTrace();
        }
      }

At the wizard page i call this method like this,

    btnUnzip.addListener(SWT.Selection, new Listener() {

            @Override
            public void handleEvent(Event event) {

                    File file = new File(text.getText());
                    File file1 = new File(textToSaveUnzipFile.getText());
                    UnzipUtility.extract(file, file1);
      }
   }

Body:
If you are using a JFace Wizard you can use the built in progress monitor in the wizard.

In the Constructor of your Wizard class call:

setNeedsProgressMonitor(true);

To show progress call

getContainer().run(true, true, runnable);

This call can be in the Wizard or a WizardPage.

where runnable is a class implementing IRunnableWithProgress. The run method of this class will look something like:

@Override
public void run(final IProgressMonitor monitor)
  throws InterruptedException
{
  monitor.beginTask("Title", .. number of work steps ..);

  try
   {
     while (not finished) {
        ... do a small amount of work

        // Update progress
        monitor.worked(1);
     }
   }
  finally
   {
     monitor.done();
   }
}


问:
How to get sbt to stop trying to pull latest transitive range dependency on each build
We are using a library that depends on Amazon's Kinesis client.  The client library itself has a transitive 'range' dependency on a number of aws core libraries.

Unfortunately, our build/update has slowed down significantly since we started using this library.  Is there a way to tell sbt to use a specific version without checking if that is the latest every time?

答:
As soon as you're dealing with Ivy's dynamic revisions feature, you have two problems to contend with:

slow builds due to dependency resolution taking a very long time, and

your builds are no longer reproducible.

Although you don't mention it in your question, I think this second problem is the more serious of the two so let's consider it first. Irreproducible builds are something that Havoc Pennington has written about:

If your build depends on a non-exact dependency version (like
  “somelibrary >= 3.1”), and the exact version gets recomputed every
  time you run the build, your project is broken.

You can no longer build old versions and get the same results.

Want to cut a bugfixes-only release from an old branch? Sorry.

Want to use git bisect? Nope.

You can’t rely on your code working because it will change by itself. Maybe it worked today, but that doesn’t mean it will work
  tomorrow. Maybe it worked in continuous integration, but that doesn’t
  mean it will work when deployed.
  Wondering whether any dependency versions changed and when? No way to figure it out.

Package management and build tools should get this right by default.
  It is a real problem; I’ve seen it bite projects I’m working on
  countless times.

He goes on to say:

What’s the solution? I’d argue that it’s been well-known for a while.
  Persist the output of the dependency resolution process and keep it in
  version control.

This is exactly what npm's package-lock.json and yarn's yarn.lock try to achieve. So, does sbt have an equivalent feature? Not really. It's on their radar, but there's nothing like a lockfile available out of the box as of sbt 0.13.15.

What can we do? We could add dependency overrides for specific versions of each of our transitive dependencies. Let's pick on the jQuery UI bower WebJar as an example. Imagine you have this in your build.sbt:

```<code>libraryDependencies += "org.webjars.bower" % "jquery-ui" % "1.12.1"
</code>```

If you look at its pom you'll see it has a dependency on jQuery with a version range of [1.6,). We could lock this range down to a specific version by adding an override like this to our build.sbt:

```<code>dependencyOverrides += "org.webjars.bower" % "jquery" % "3.2.1"
</code>```

This is probably tolerable for our jQuery UI example, but as our list of dependencies grows, it becomes boring and error prone to do this manually. What is the complete list of dependencies? Which versions should we use as overrides?

Fortunately, there's an sbt plugin called sbt-lock that will take care of it for you. Quoting from sbt-lock's README:

Add the following line to ~/.sbt/0.13/plugins/sbt-lock.sbt or
  project/plugins.sbt.

addSbtPlugin("com.github.tkawachi" % "sbt-lock" % "0.3.0")

lock to create lock.sbt file. lock.sbt includes dependencyOverrides for all dependent library versions. Manage it with
  version control system.
      unlock to delete lock.sbt file.

So we've solved the problem of irreproducible builds, but does this improve the build time? I was hoping it would but it looks like it doesn't. I was hoping sbt would notice the dependency overrides and not bother to do the (now unnecessary) expensive dependency resolution, but it looks like it does the expensive resolution anyway (and then overrides the result of the expensive resolution).

So we need a bigger hammer. The only solution I'm aware of is to spin up a local Nexus repository, configure it as a proxy/cache for all the repos your build requires (Maven Central, etc) and then force your sbt build to use this (and only this) local Nexus to resolve dependencies. This approach is something that Timothy Perrett wrote about a couple of years ago (emphasis mine):

In many Scala project builds - regardless of if its on travis-ci.org,
  on-premise[s] Jenkins or otherwise - a large portion of the overall build
  time is spent in doing dependency resolution. This is further
  aggravated when builds used Ivy's dynamic revision feature, as updates
  need to be calculated for each build, regardless of the Ivy local
  cache.

He lists the following steps (read his whole post for more details):

Install a local Nexus. On macOS I use Homebrew and brew install nexus.

Set up proxy repos.

Configure sbt to use the proxy repos (in file $HOME/.sbt/repositories).

Configure sbt to use only the repos defined in $HOME/.sbt/repositories. He lists a few ways to achieve this. Read his post and the  proxy repos section of the sbt docs for more details and motivation.

An alternative to spinning up a local Nexus might be to use sbt's experimental cached resolution:

```<code>updateOptions := updateOptions.value.withCachedResolution(true)
</code>```

Body:
As soon as you're dealing with Ivy's dynamic revisions feature, you have two problems to contend with:

slow builds due to dependency resolution taking a very long time, and

your builds are no longer reproducible.

Although you don't mention it in your question, I think this second problem is the more serious of the two so let's consider it first. Irreproducible builds are something that Havoc Pennington has written about:

If your build depends on a non-exact dependency version (like
  “somelibrary >= 3.1”), and the exact version gets recomputed every
  time you run the build, your project is broken.

You can no longer build old versions and get the same results.

Want to cut a bugfixes-only release from an old branch? Sorry.

Want to use git bisect? Nope.

You can’t rely on your code working because it will change by itself. Maybe it worked today, but that doesn’t mean it will work
  tomorrow. Maybe it worked in continuous integration, but that doesn’t
  mean it will work when deployed.
  Wondering whether any dependency versions changed and when? No way to figure it out.

Package management and build tools should get this right by default.
  It is a real problem; I’ve seen it bite projects I’m working on
  countless times.

He goes on to say:

What’s the solution? I’d argue that it’s been well-known for a while.
  Persist the output of the dependency resolution process and keep it in
  version control.

This is exactly what npm's package-lock.json and yarn's yarn.lock try to achieve. So, does sbt have an equivalent feature? Not really. It's on their radar, but there's nothing like a lockfile available out of the box as of sbt 0.13.15.

What can we do? We could add dependency overrides for specific versions of each of our transitive dependencies. Let's pick on the jQuery UI bower WebJar as an example. Imagine you have this in your build.sbt:

libraryDependencies += "org.webjars.bower" % "jquery-ui" % "1.12.1"

If you look at its pom you'll see it has a dependency on jQuery with a version range of [1.6,). We could lock this range down to a specific version by adding an override like this to our build.sbt:

dependencyOverrides += "org.webjars.bower" % "jquery" % "3.2.1"

This is probably tolerable for our jQuery UI example, but as our list of dependencies grows, it becomes boring and error prone to do this manually. What is the complete list of dependencies? Which versions should we use as overrides?

Fortunately, there's an sbt plugin called sbt-lock that will take care of it for you. Quoting from sbt-lock's README:

Add the following line to ~/.sbt/0.13/plugins/sbt-lock.sbt or
  project/plugins.sbt.

addSbtPlugin("com.github.tkawachi" % "sbt-lock" % "0.3.0")

lock to create lock.sbt file. lock.sbt includes dependencyOverrides for all dependent library versions. Manage it with
  version control system.
      unlock to delete lock.sbt file.

So we've solved the problem of irreproducible builds, but does this improve the build time? I was hoping it would but it looks like it doesn't. I was hoping sbt would notice the dependency overrides and not bother to do the (now unnecessary) expensive dependency resolution, but it looks like it does the expensive resolution anyway (and then overrides the result of the expensive resolution).

So we need a bigger hammer. The only solution I'm aware of is to spin up a local Nexus repository, configure it as a proxy/cache for all the repos your build requires (Maven Central, etc) and then force your sbt build to use this (and only this) local Nexus to resolve dependencies. This approach is something that Timothy Perrett wrote about a couple of years ago (emphasis mine):

In many Scala project builds - regardless of if its on travis-ci.org,
  on-premise[s] Jenkins or otherwise - a large portion of the overall build
  time is spent in doing dependency resolution. This is further
  aggravated when builds used Ivy's dynamic revision feature, as updates
  need to be calculated for each build, regardless of the Ivy local
  cache.

He lists the following steps (read his whole post for more details):

Install a local Nexus. On macOS I use Homebrew and brew install nexus.

Set up proxy repos.

Configure sbt to use the proxy repos (in file $HOME/.sbt/repositories).

Configure sbt to use only the repos defined in $HOME/.sbt/repositories. He lists a few ways to achieve this. Read his post and the  proxy repos section of the sbt docs for more details and motivation.

An alternative to spinning up a local Nexus might be to use sbt's experimental cached resolution:

updateOptions := updateOptions.value.withCachedResolution(true)


问:
Strange output with Array.filter() method
In the code below I expected the result of destroyer([1, 2, 3, 1, 2, 3], 2, 3); would be [1,1].

But the result pops out to be [1,2,3,1,2,3].

Where am I going wrong?

```<code>function destroyer(arr) {
  function hlp(x) {
    for(var i=1; i<arguments.length ; i++) {
      if(x == arguments[i]) return false;
    }
    return true;
  }
  return arr.filter(hlp);
}
console.log(destroyer([1, 2, 3, 1, 2, 3], 2, 3));
</code>```

答:
Solved in two ways:

1st:

```<code>function destroyer(arr) {
  function hlp(x) {
    for(var i=1; i<destroyer.arguments.length ; i++) {
      if(x == destroyer.arguments[i]) return false;
    }
    return true;
  }
  return arr.filter(hlp);
}
console.log(destroyer([1, 2, 3, 1, 2, 3], 2, 3));
</code>```

2nd

Look to the solution posted by @Nenad Vracar

Body:
In the code below I expected the result of destroyer([1, 2, 3, 1, 2, 3], 2, 3); would be [1,1].

But the result pops out to be [1,2,3,1,2,3].

Where am I going wrong?

function destroyer(arr) {
  function hlp(x) {
    for(var i=1; i<arguments.length ; i++) {
      if(x == arguments[i]) return false;
    }
    return true;
  }
  return arr.filter(hlp);
}
console.log(destroyer([1, 2, 3, 1, 2, 3], 2, 3));

Body:
Solved in two ways:

1st:

function destroyer(arr) {
  function hlp(x) {
    for(var i=1; i<destroyer.arguments.length ; i++) {
      if(x == destroyer.arguments[i]) return false;
    }
    return true;
  }
  return arr.filter(hlp);
}
console.log(destroyer([1, 2, 3, 1, 2, 3], 2, 3));

2nd

Look to the solution posted by @Nenad Vracar


问:
Repair normals on possibly bad .stl files
I am new to Three.js and have been assigned the task of trying to repair the normals on files that have been coming in occasionally that appear to be bad. We do not know if they are bad scans or possibly bad uploads. We are looking into the upload function, but also would like to try and repair them if possible. Can anyone provide any ideas or tips to repair the file or find the correct normals?

Below is the code where we grab the normals and how we grab them. NOTE: this code works fine generally, it is only a problem when the normals are bad. I am also attaching one of the files so you can see the types of normals and "bad file" I am dealing with. Get File here

We are also using VTK on the backend with C++, so a solution or idea using either of these is helpful.

```<code>my.geometry = geometry;

    var front = new THREE.MeshPhongMaterial(
    {color: 0xe2e4dc, shininess: 50, side: THREE.DoubleSide});

var mesh = [new THREE.Mesh(geometry, front)];

my.scene.add(mesh[0]);
my.objects.push(mesh[0]);

var rc = new THREE.Raycaster();

var modelData = {'objects': [mesh[0].id], 'id': mesh[0].id};

var normalFound = false;
for (var dy = 80; dy >= -80; dy = dy - 10) {
  console.log('finding a normal on', 0, dy, -200);
  rc.set(new THREE.Vector3(0, dy, -200), new THREE.Vector3(0, 0, 1));

  var hit = rc.intersectObjects([mesh[0]]);

  if (hit.length) {
    my.normal = hit[0].face.normal.normalize();
    console.log('normal', my.normal.z);

    modelData['normal'] = my.normal;

    if ((my.normal.z > 0.9 && my.normal.z < 1.1)) {
      my.requireOrienteering = true;
      modelData['arch'] = 'lower';
      normalFound = true;
      console.log('we have a lower arch');
    } else if ((my.normal.z < -0.9 && my.normal.z > -1.1)) {
      modelData['arch'] = 'upper';
      normalFound = true;
      console.log('we have an upper arch');
      }

    break;
  }
}
</code>```

答:
Calculating the normals is an easy step. If you calculate the cross product of two vectors (geometrical one), you will get a vector, that is orthogonal to the two, you input. All you have to do now is normalize it, since normals should be normalised to not mess up lightning calculations.

For smooth surfaces, you have to calculate all normals on the point and average them. For flat surfaces each vertex has multiple normales (one for each surface).

In pseudo code it will look like this for quads:

```<code>foreach quad : mesh
foreach vertex : quad
    vector1 = neighborVertex.pos - vertex.pos;
    vector2 = otherNeighborVertex.pos - vertex.pos;
    vertex.normal = normalize(cross(vector1, vector2));
end foreach;
end foreach;
</code>```

Body:
I am new to Three.js and have been assigned the task of trying to repair the normals on files that have been coming in occasionally that appear to be bad. We do not know if they are bad scans or possibly bad uploads. We are looking into the upload function, but also would like to try and repair them if possible. Can anyone provide any ideas or tips to repair the file or find the correct normals?

Below is the code where we grab the normals and how we grab them. NOTE: this code works fine generally, it is only a problem when the normals are bad. I am also attaching one of the files so you can see the types of normals and "bad file" I am dealing with. Get File here

We are also using VTK on the backend with C++, so a solution or idea using either of these is helpful.

my.geometry = geometry;

    var front = new THREE.MeshPhongMaterial(
    {color: 0xe2e4dc, shininess: 50, side: THREE.DoubleSide});

var mesh = [new THREE.Mesh(geometry, front)];

my.scene.add(mesh[0]);
my.objects.push(mesh[0]);

var rc = new THREE.Raycaster();

var modelData = {'objects': [mesh[0].id], 'id': mesh[0].id};

var normalFound = false;
for (var dy = 80; dy >= -80; dy = dy - 10) {
  console.log('finding a normal on', 0, dy, -200);
  rc.set(new THREE.Vector3(0, dy, -200), new THREE.Vector3(0, 0, 1));

  var hit = rc.intersectObjects([mesh[0]]);

  if (hit.length) {
    my.normal = hit[0].face.normal.normalize();
    console.log('normal', my.normal.z);

    modelData['normal'] = my.normal;

    if ((my.normal.z > 0.9 && my.normal.z < 1.1)) {
      my.requireOrienteering = true;
      modelData['arch'] = 'lower';
      normalFound = true;
      console.log('we have a lower arch');
    } else if ((my.normal.z < -0.9 && my.normal.z > -1.1)) {
      modelData['arch'] = 'upper';
      normalFound = true;
      console.log('we have an upper arch');
      }

    break;
  }
}

Body:
Calculating the normals is an easy step. If you calculate the cross product of two vectors (geometrical one), you will get a vector, that is orthogonal to the two, you input. All you have to do now is normalize it, since normals should be normalised to not mess up lightning calculations.

For smooth surfaces, you have to calculate all normals on the point and average them. For flat surfaces each vertex has multiple normales (one for each surface).

In pseudo code it will look like this for quads:

foreach quad : mesh
foreach vertex : quad
    vector1 = neighborVertex.pos - vertex.pos;
    vector2 = otherNeighborVertex.pos - vertex.pos;
    vertex.normal = normalize(cross(vector1, vector2));
end foreach;
end foreach;


问:
What simple guidelines would you give your developers for writing good SQL against Oracle?
I work in a group of about 25 developers.  I'm responsible for coming up with the database design (tables, views, etc) and am called apon for performance tuning when necessary.

There are a couple of different applications that connect.  Database access is via JDBC, hibernate, and iBatis SQL maps.  Developers with various levels of experience write SQL statements.

What guidelines would you give to developers to write good SQL?

By good I mean: correct, performs well, easy to understand and maintain.

These are just meant to be easy to follow guidelines - I want to get people onto the right track for the majority of situations.  We will break these guidelines when it makes sense.

EDIT: We have in place code reviews for all source commits (SQL, java, etc) enforced through a jira workflow.

答:
If you are a database developer, you need to know what an EXECUTION PLAN is. If you don't then go mine coal or something.

Before developing:

first, you think what best EXECUTION PLAN will be,

second you create tables and indexes, and

third you use hints to persuade the optimizer to come out with the plan you made.

You do use hints. Forget automatic optimization, it's a marketing myth. No optimizer knows your data better than you and never will.

There are no "programmers who create queries" and "system administrators who create indexes". Programmers program, system administrators make backups (or whatever they make).

Triggers are evil.

Prefix you columns, tables and views (SELECT prs_name FROM t_person)

Make lines and indent

OwnerDisplayName: WW

ContentLicense: CC BY-SA 2.5

LastEditorDisplayName: WW

OwnerDisplayName: Quassnoi


问:
Is a RESTful url valid without ids between objects?
I have two RESTful API design questions.  Let's say I have a fruitstand web app.  I want to return information about all the fruits I carry and the counts those fruits, and I do it with:

```<code>http://myfruitstand.com/fruits
</code>```

Question 1:
If I have 10 oranges, then I'm thinking that I can get information about a particular orange with:

```<code>http://myfruitstand.com/fruits/oranges/3
</code>```

But is the above url RESTful--don't I need an id between 'fruits' and 'oranges' to conform to REST standards?  Or is this url with 'fruits' being immediately followed with the subclass 'oranges' okay?

Question 2:
Similarly, if I want to have a discussion forum about my oranges (not a particular orange), can I put it here:

```<code>http://myfruitstand.com/fruits/oranges/comments
</code>```

Again, is the above url RESTful since there's no id between 'oranges' and 'comments' (an id here, of course, would imply a discussion about a particular orange and I don't want that)?  Here, there's no subclass rational of 'oranges' being immediately followed by 'comments.'

thanks in advance, Chuck

答: Yes all urls are restful as long as they are deterministic. Restful is more about the http-methods you are using (DELETE for instance to delete, POST to edit, GET to read, ...).</p>

Body:
I have two RESTful API design questions.  Let's say I have a fruitstand web app.  I want to return information about all the fruits I carry and the counts those fruits, and I do it with:

http://myfruitstand.com/fruits

Question 1:
If I have 10 oranges, then I'm thinking that I can get information about a particular orange with:

http://myfruitstand.com/fruits/oranges/3

But is the above url RESTful--don't I need an id between 'fruits' and 'oranges' to conform to REST standards?  Or is this url with 'fruits' being immediately followed with the subclass 'oranges' okay?

Question 2:
Similarly, if I want to have a discussion forum about my oranges (not a particular orange), can I put it here:

http://myfruitstand.com/fruits/oranges/comments

Again, is the above url RESTful since there's no id between 'oranges' and 'comments' (an id here, of course, would imply a discussion about a particular orange and I don't want that)?  Here, there's no subclass rational of 'oranges' being immediately followed by 'comments.'

thanks in advance, Chuck


问:
How to test http error handlers in angular?
Here is sample of the code:

```<code>this.paymentTypesService.updatePaymentTypesOrder('cashout', newOrder).subscribe(() => {
  this.notificationsService.success(
    'Success!',
    `Order change saved successfully`,
    { showProgressBar: true, pauseOnHover: true, clickToClose: true }
  );
}, () => {
  this.notificationsService.error(
    'Error',
    `Order change save failed`,
    { showProgressBar: true, pauseOnHover: true, clickToClose: true }
  );
});
</code>```

There is simple Http service behind the paymentTypesService methods... How should I test the error handler in such case?

答:
SOmething like this should work:

spyOn(paymentTypesService, 'updatePaymentTypesOrder').and.returnValue(Observable.throw(new Error()))

Body:
Here is sample of the code:

this.paymentTypesService.updatePaymentTypesOrder('cashout', newOrder).subscribe(() => {
  this.notificationsService.success(
    'Success!',
    `Order change saved successfully`,
    { showProgressBar: true, pauseOnHover: true, clickToClose: true }
  );
}, () => {
  this.notificationsService.error(
    'Error',
    `Order change save failed`,
    { showProgressBar: true, pauseOnHover: true, clickToClose: true }
  );
});

There is simple Http service behind the paymentTypesService methods... How should I test the error handler in such case?


问:
Long Double in Swift
In C, there is a type called long double, which on my machine is 16-bytes (128-bit). Is there any way to store a long double in Swift? I've tried type aliases (typedefs) of long double from an Objective-C header, but it doesn't show up in Swift. And functions returning long double (powl, sqrtl) don't show up neither.

I know there's a Float80 but that's only 80 bits, not 128 bits.

答: Unless you have a POWER processor, your 128 bit long double is actually an 80 bits extended precision number, plus 48 bit wasted. </p>

Title: Long Double in Swift


问:
why is if(!$_SESSION['dbname']){} returning false?
im not able to create a session.

my php code is

```<code><?php

          $dbhost = "localhost";
          $dbuser = "root";
          $dbpassword = "";
          $dbname = "dany";
          $query = "";
          $sqlQuery = "";
          $row = "";
          $username=false;
          if(isset($_POST['n'])){
              $username=$_POST['n'];
           }
          $password= false;
          if(isset($_POST['p'])){
              $password= $_POST['p'];
          }
          $conn=mysqli_connect($dbhost,$dbuser,$dbpassword,$dbname);
          $sUser=mysqli_real_escape_string($conn,$username);
          $sPass=mysqli_real_escape_string($conn,$password);
          // For Security
          $query="SELECT * From admin where username='$sUser' and password='$sPass'";
          $result=mysqli_query($conn,$query);
          if(mysqli_num_rows($result)==1)
          {
              session_start();
              $_SESSION['dany']= $dbname;
              header('location:adminPanel.php');
          }
?>
</code>```

the other code where the session is checked, the code is:

```<code><?php
session_start();
if(!$_SESSION['dany'])
{
    header('location:adminLogin.php');
}
?>
</code>```

here the line:

```<code>if(!$_SESSION['dany'])
</code>```

is returning false for every valid input i give as well as for the invalid inputs.
i tried to copy the whole code and create a new dummy project, it worked there. but is not working in my actula project.

答:
You need to check if the dany entry defined with isset:

```<code>if(isset($_SESSION['dany'])){
</code>```

Body:
im not able to create a session.

my php code is

<?php

          $dbhost = "localhost";
          $dbuser = "root";
          $dbpassword = "";
          $dbname = "dany";
          $query = "";
          $sqlQuery = "";
          $row = "";
          $username=false;
          if(isset($_POST['n'])){
              $username=$_POST['n'];
           }
          $password= false;
          if(isset($_POST['p'])){
              $password= $_POST['p'];
          }
          $conn=mysqli_connect($dbhost,$dbuser,$dbpassword,$dbname);
          $sUser=mysqli_real_escape_string($conn,$username);
          $sPass=mysqli_real_escape_string($conn,$password);
          // For Security
          $query="SELECT * From admin where username='$sUser' and password='$sPass'";
          $result=mysqli_query($conn,$query);
          if(mysqli_num_rows($result)==1)
          {
              session_start();
              $_SESSION['dany']= $dbname;
              header('location:adminPanel.php');
          }
?>

the other code where the session is checked, the code is:

<?php
session_start();
if(!$_SESSION['dany'])
{
    header('location:adminLogin.php');
}
?>

here the line:

if(!$_SESSION['dany'])

is returning false for every valid input i give as well as for the invalid inputs.
i tried to copy the whole code and create a new dummy project, it worked there. but is not working in my actula project.

Body:
You need to check if the dany entry defined with isset:

if(isset($_SESSION['dany'])){


问:
SQLConnection code
When trying to establish a connection I get the exception below:

```<code>System.Data.SqlClient.SqlException occurred
  HResult=0x80131904
  Message=Login failed for user ''.
  Source=.Net SqlClient Data Provider
  StackTrace:
<Cannot evaluate the exception stack trace>
</code>```

I keep getting the above error, here is my code:

```<code>SqlConnection conn =
  new SqlConnection(@"Data Source = Computer-DELL\SQLEXPRESS;Initial Catalog = Drivers");

conn.open();
</code>```

答:
Your connection string does not have Username and Password  and or Integrated Security.

With Integrated Security:

```<code>Data Source=localhost\SQLSERVER;Initial Catalog=YourDataBaseName;Integrated Security=True;
</code>```

With username and password:

```<code>Data Source=localhost\SQLSERVER;Initial Catalog=YourDataBaseName;persist security info=True;user id=someusername;password=somepassword;
</code>```

Title: SQLConnection code

Body:
When trying to establish a connection I get the exception below:

System.Data.SqlClient.SqlException occurred
  HResult=0x80131904
  Message=Login failed for user ''.
  Source=.Net SqlClient Data Provider
  StackTrace:
<Cannot evaluate the exception stack trace>

I keep getting the above error, here is my code:

SqlConnection conn =
  new SqlConnection(@"Data Source = Computer-DELL\SQLEXPRESS;Initial Catalog = Drivers");

conn.open();

Body:
Your connection string does not have Username and Password  and or Integrated Security.

With Integrated Security:

Data Source=localhost\SQLSERVER;Initial Catalog=YourDataBaseName;Integrated Security=True;

With username and password:

Data Source=localhost\SQLSERVER;Initial Catalog=YourDataBaseName;persist security info=True;user id=someusername;password=somepassword;


问:
Google Script get PDF document dimensions
Is there a way I can retrieve the document dimensions of a PDF file using Google Scripts?</p>

答:
As of now there is no mention of fetching the PDF dimensions in Apps Script Drive Files. There's only PAGE_HEIGHT and PAGE_HEIGHT E

Check: Attribute for documents


问:
Is there a class or namespace feature within AutoIt?
I have multiple files using the same function names. Is there a way to differentiate the two?</p>

答: AutoIt does not provide a method to do this. You will need to give each function a unique name. You could prepend the filename onto the function name, kind of a poor-man's namespace.</p>


问:
How to avoid module conflicts in Rails?
I have model in rails app named Benchmark, although ruby requires its Benchmark module by default when starting process.

Is there anyway I can unload Benchmark module in order to use my Benchmark model?

答:
You can instead use a namespaced model.

```<code>module Myapp
  class Benchmark < ActiveRecord::Base
  end
end
</code>```

You may need to specify the table name.

If I were you, I would just a different name for the model, e.g. Yardstick or Indicator or MyBenchmark.

Title: How to avoid module conflicts in Rails?

Body:
You can instead use a namespaced model.

module Myapp
  class Benchmark < ActiveRecord::Base
  end
end

You may need to specify the table name.

If I were you, I would just a different name for the model, e.g. Yardstick or Indicator or MyBenchmark.


问:
How do I run a Gradle project in the IntelliJ
I cloned a repo from Github and I would like to run it in the IntellIJ. The build tool used is Gradle and I have zero experience so far. The build.gradle file is provided below,

```<code>apply plugin: 'java'
//apply plugin: 'eclipse-wtp'
apply plugin: 'maven'
apply plugin: 'spring-boot'

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

buildscript {
    ext {
        springBootVersion = '1.3.0.RELEASE'
    }
    repositories {
        mavenCentral()
        maven { url "http://repo.spring.io/libs-release" }
        maven { url "http://repo.spring.io/milestone" }
        maven { url "http://repo.spring.io/snapshot" }
    }

    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

repositories {
    mavenCentral()
    maven { url "http://repo.spring.io/libs-release" }
    maven { url "http://repo.spring.io/milestone" }
    maven { url "http://repo.spring.io/snapshot" }
}

ext {
    commonsPoolVersion = '2.4.2'
    nettyVersion = '4.0.33.Final'
    reactorVersion = '2.0.7.RELEASE'
    redisVersion = '0.6'
    springSessionVersion = '1.1.0.M1'
}

dependencies {
    compile("org.springframework.boot:spring-boot-starter-security")
    compile("org.springframework.boot:spring-boot-starter-web")
    compile("org.springframework.boot:spring-boot-starter-websocket")
    compile("org.springframework.boot:spring-boot-starter-actuator")
    compile("org.springframework.boot:spring-boot-starter-redis")

    compile("org.springframework.security:spring-security-messaging")
    compile("org.springframework.session:spring-session:$springSessionVersion")
    compile("org.apache.commons:commons-pool2:$commonsPoolVersion")
    compile("com.github.kstyrc:embedded-redis:$redisVersion")
    compile("io.projectreactor:reactor-core:${reactorVersion}")
    compile("io.projectreactor:reactor-net:${reactorVersion}") {
        exclude group: "io.netty", module: "netty-all"
    }
    compile("io.netty:netty-all:$nettyVersion")

    testCompile("org.springframework.boot:spring-boot-starter-test")
}

eclipse {
    classpath {
         containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER')
         containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8'
    }
}
</code>```

I have installed the gradle using brew and the installation location is /usr/local/opt/gradle. In the IntelliJ, I have set the GRADLE_HOME as /usr/local/opt/gradle/libexec.

When I run the project with command gradle bootRun --stacktrace, I get the following error message,

```<code>FAILURE: Build failed with an exception.

* Where:
Build file '/Users/Mockyenl/IdeaProjects/spring-websocket-chat/build.gradle' line: 4

* What went wrong:
A problem occurred evaluating root project 'spring-websocket-chat'.
> Failed to apply plugin [class 'io.spring.gradle.dependencymanagement.DependencyManagementPlugin']
   > Could not create task of type 'DependencyManagementReportTask'.

* Try:
Run with --info or --debug option to get more log output.

* Exception is:
org.gradle.api.GradleScriptException: A problem occurred evaluating root project 'spring-websocket-chat'.
        at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:92)
        at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl$2.run(DefaultScriptPluginFactory.java:187)
        at org.gradle.configuration.ProjectScriptTarget.addConfiguration(ProjectScriptTarget.java:77)
        at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:192)
        at org.gradle.configuration.BuildOperationScriptPlugin$1.run(BuildOperationScriptPlugin.java:61)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:317)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:309)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:185)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:95)
        at org.gradle.configuration.BuildOperationScriptPlugin.apply(BuildOperationScriptPlugin.java:58)
        at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:39)
        at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:26)
        at org.gradle.configuration.project.ConfigureActionsProjectEvaluator.evaluate(ConfigureActionsProjectEvaluator.java:34)
        at org.gradle.configuration.project.LifecycleProjectEvaluator.doConfigure(LifecycleProjectEvaluator.java:63)
        at org.gradle.configuration.project.LifecycleProjectEvaluator.access$100(LifecycleProjectEvaluator.java:33)
        at org.gradle.configuration.project.LifecycleProjectEvaluator$ConfigureProject.run(LifecycleProjectEvaluator.java:103)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:317)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:309)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:185)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:95)
        at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:49)
        at org.gradle.api.internal.project.DefaultProject.evaluate(DefaultProject.java:654)
        at org.gradle.api.internal.project.DefaultProject.evaluate(DefaultProject.java:132)
        at org.gradle.execution.TaskPathProjectEvaluator.configure(TaskPathProjectEvaluator.java:35)
        at org.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(TaskPathProjectEvaluator.java:60)
        at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:38)
        at org.gradle.initialization.DefaultGradleLauncher$ConfigureBuild.run(DefaultGradleLauncher.java:195)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:317)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:309)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:185)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:95)
        at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:157)
        at org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGradleLauncher.java:44)
        at org.gradle.initialization.DefaultGradleLauncher$1.run(DefaultGradleLauncher.java:122)
        at org.gradle.internal.work.DefaultWorkerLeaseService$2.execute(DefaultWorkerLeaseService.java:124)
        at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:116)
        at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:99)
        at org.gradle.launcher.exec.GradleBuildController.run(GradleBuildController.java:66)
        at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28)
        at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
        at org.gradle.tooling.internal.provider.ValidatingBuildActionRunner.run(ValidatingBuildActionRunner.java:32)
        at org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner$1.run(RunAsBuildOperationBuildActionRunner.java:43)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:317)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:309)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:185)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:95)
        at org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner.run(RunAsBuildOperationBuildActionRunner.java:40)
        at org.gradle.tooling.internal.provider.SubscribableBuildActionRunner.run(SubscribableBuildActionRunner.java:51)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:44)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28)
        at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:75)
        at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:49)
        at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:51)
        at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:32)
        at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:36)
        at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:25)
        at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:64)
        at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:29)
        at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:55)
        at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:42)
        at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:50)
        at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:30)
        at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:67)
        at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:37)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74)
        at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72)
        at org.gradle.util.Swapper.swap(Swapper.java:38)
        at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.exec.LogAndCheckHealth.execute(LogAndCheckHealth.java:55)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:62)
        at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:72)
        at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50)
        at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:297)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
        at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:46)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
Caused by: org.gradle.api.internal.plugins.PluginApplicationException: Failed to apply plugin [class 'io.spring.gradle.dependencymanagement.DependencyManagementPlugin']
        at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(DefaultPluginManager.java:150)
        at org.gradle.api.internal.plugins.DefaultPluginManager.addImperativePlugin(DefaultPluginManager.java:80)
        at org.gradle.api.internal.plugins.DefaultPluginManager.addImperativePlugin(DefaultPluginManager.java:86)
        at org.gradle.api.internal.plugins.DefaultPluginContainer.apply(DefaultPluginContainer.java:60)
        at org.springframework.boot.gradle.dependencymanagement.DependencyManagementPluginFeatures.apply(DependencyManagementPluginFeatures.java:44)
        at org.springframework.boot.gradle.SpringBootPlugin.apply(SpringBootPlugin.java:47)
        at org.springframework.boot.gradle.SpringBootPlugin.apply(SpringBootPlugin.java:38)
        at org.gradle.api.internal.plugins.ImperativeOnlyPluginTarget.applyImperative(ImperativeOnlyPluginTarget.java:41)
        at org.gradle.api.internal.plugins.RuleBasedPluginTarget.applyImperative(RuleBasedPluginTarget.java:49)
        at org.gradle.api.internal.plugins.DefaultPluginManager.addPlugin(DefaultPluginManager.java:165)
        at org.gradle.api.internal.plugins.DefaultPluginManager.access$200(DefaultPluginManager.java:47)
        at org.gradle.api.internal.plugins.DefaultPluginManager$AddPluginBuildOperation.run(DefaultPluginManager.java:252)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:317)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:309)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:185)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:95)
        at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(DefaultPluginManager.java:144)
        at org.gradle.api.internal.plugins.DefaultPluginManager.apply(DefaultPluginManager.java:125)
        at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.applyType(DefaultObjectConfigurationAction.java:113)
        at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.access$200(DefaultObjectConfigurationAction.java:36)
        at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction$3.run(DefaultObjectConfigurationAction.java:80)
        at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.execute(DefaultObjectConfigurationAction.java:136)
        at org.gradle.api.internal.project.AbstractPluginAware.apply(AbstractPluginAware.java:46)
        at org.gradle.api.internal.project.ProjectScript.apply(ProjectScript.java:34)
        at org.gradle.api.Script$apply$0.callCurrent(Unknown Source)
        at build_4b35wimvl540y84qjn2xnlyq9.run(/Users/Chaklader/IdeaProjects/spring-websocket-chat/build.gradle:4)
        at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:90)
        ... 88 more
Caused by: org.gradle.api.tasks.TaskInstantiationException: Could not create task of type 'DependencyManagementReportTask'.
        at org.gradle.api.internal.project.taskfactory.TaskFactory$1.call(TaskFactory.java:123)
        at org.gradle.api.internal.project.taskfactory.TaskFactory$1.call(TaskFactory.java:118)
        at org.gradle.util.GUtil.uncheckedCall(GUtil.java:402)
        at org.gradle.api.internal.AbstractTask.injectIntoNewInstance(AbstractTask.java:174)
        at org.gradle.api.internal.project.taskfactory.TaskFactory.create(TaskFactory.java:118)
        at org.gradle.api.internal.project.taskfactory.TaskFactory.create(TaskFactory.java:38)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory.create(AnnotationProcessingTaskFactory.java:51)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory.create(AnnotationProcessingTaskFactory.java:32)
        at org.gradle.api.internal.project.taskfactory.DependencyAutoWireTaskFactory.create(DependencyAutoWireTaskFactory.java:44)
        at org.gradle.api.internal.project.taskfactory.DependencyAutoWireTaskFactory.create(DependencyAutoWireTaskFactory.java:27)
        at org.gradle.api.internal.tasks.DefaultTaskContainer$TaskInstantiator.create(DefaultTaskContainer.java:301)
        at org.gradle.api.internal.tasks.DefaultTaskContainer$TaskInstantiator.create(DefaultTaskContainer.java:289)
        at org.gradle.api.internal.tasks.DefaultTaskContainer.create(DefaultTaskContainer.java:116)
        at org.gradle.api.internal.tasks.DefaultTaskContainer.create(DefaultTaskContainer.java:147)
        at org.gradle.api.internal.tasks.DefaultTaskContainer_Decorated.create(Unknown Source)
        at org.gradle.api.internal.tasks.DefaultTaskContainer_Decorated$create.call(Unknown Source)
        at io.spring.gradle.dependencymanagement.DependencyManagementPlugin.apply(DependencyManagementPlugin.groovy:57)
        at io.spring.gradle.dependencymanagement.DependencyManagementPlugin.apply(DependencyManagementPlugin.groovy)
        at org.gradle.api.internal.plugins.ImperativeOnlyPluginTarget.applyImperative(ImperativeOnlyPluginTarget.java:41)
        at org.gradle.api.internal.plugins.RuleBasedPluginTarget.applyImperative(RuleBasedPluginTarget.java:49)
        at org.gradle.api.internal.plugins.DefaultPluginManager.addPlugin(DefaultPluginManager.java:165)
        at org.gradle.api.internal.plugins.DefaultPluginManager.access$200(DefaultPluginManager.java:47)
        at org.gradle.api.internal.plugins.DefaultPluginManager$AddPluginBuildOperation.run(DefaultPluginManager.java:252)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:317)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:309)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:185)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:95)
        at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(DefaultPluginManager.java:144)
        ... 114 more
Caused by: org.gradle.internal.service.UnknownServiceException: No service of type StyledTextOutputFactory available in ProjectScopeServices.
        at org.gradle.internal.service.DefaultServiceRegistry.getServiceProvider(DefaultServiceRegistry.java:352)
        at org.gradle.internal.service.DefaultServiceRegistry.doGet(DefaultServiceRegistry.java:341)
        at org.gradle.internal.service.DefaultServiceRegistry.get(DefaultServiceRegistry.java:329)
        at org.gradle.api.internal.DependencyInjectingInstantiator.convertParameters(DependencyInjectingInstantiator.java:85)
        at org.gradle.api.internal.DependencyInjectingInstantiator.newInstance(DependencyInjectingInstantiator.java:54)
        at org.gradle.api.internal.ClassGeneratorBackedInstantiator.newInstance(ClassGeneratorBackedInstantiator.java:36)
        at org.gradle.api.internal.project.taskfactory.TaskFactory$1.call(TaskFactory.java:121)
        ... 141 more

BUILD FAILED in 0s
</code>```

The gradle info is here,

When I try to synchronize the project, I get the message,

How can I just run the project properly ?

答:
Try with this plugin.

```<code>plugins {
    id "io.spring.dependency-management" version "1.0.3.RELEASE"
}
</code>```

documentation here

Body:
I cloned a repo from Github and I would like to run it in the IntellIJ. The build tool used is Gradle and I have zero experience so far. The build.gradle file is provided below,

apply plugin: 'java'
//apply plugin: 'eclipse-wtp'
apply plugin: 'maven'
apply plugin: 'spring-boot'

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

buildscript {
    ext {
        springBootVersion = '1.3.0.RELEASE'
    }
    repositories {
        mavenCentral()
        maven { url "http://repo.spring.io/libs-release" }
        maven { url "http://repo.spring.io/milestone" }
        maven { url "http://repo.spring.io/snapshot" }
    }

    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

repositories {
    mavenCentral()
    maven { url "http://repo.spring.io/libs-release" }
    maven { url "http://repo.spring.io/milestone" }
    maven { url "http://repo.spring.io/snapshot" }
}

ext {
    commonsPoolVersion = '2.4.2'
    nettyVersion = '4.0.33.Final'
    reactorVersion = '2.0.7.RELEASE'
    redisVersion = '0.6'
    springSessionVersion = '1.1.0.M1'
}

dependencies {
    compile("org.springframework.boot:spring-boot-starter-security")
    compile("org.springframework.boot:spring-boot-starter-web")
    compile("org.springframework.boot:spring-boot-starter-websocket")
    compile("org.springframework.boot:spring-boot-starter-actuator")
    compile("org.springframework.boot:spring-boot-starter-redis")

    compile("org.springframework.security:spring-security-messaging")
    compile("org.springframework.session:spring-session:$springSessionVersion")
    compile("org.apache.commons:commons-pool2:$commonsPoolVersion")
    compile("com.github.kstyrc:embedded-redis:$redisVersion")
    compile("io.projectreactor:reactor-core:${reactorVersion}")
    compile("io.projectreactor:reactor-net:${reactorVersion}") {
        exclude group: "io.netty", module: "netty-all"
    }
    compile("io.netty:netty-all:$nettyVersion")

    testCompile("org.springframework.boot:spring-boot-starter-test")
}

eclipse {
    classpath {
         containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER')
         containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8'
    }
}

I have installed the gradle using brew and the installation location is /usr/local/opt/gradle. In the IntelliJ, I have set the GRADLE_HOME as /usr/local/opt/gradle/libexec.

When I run the project with command gradle bootRun --stacktrace, I get the following error message,

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/Mockyenl/IdeaProjects/spring-websocket-chat/build.gradle' line: 4

* What went wrong:
A problem occurred evaluating root project 'spring-websocket-chat'.
> Failed to apply plugin [class 'io.spring.gradle.dependencymanagement.DependencyManagementPlugin']
   > Could not create task of type 'DependencyManagementReportTask'.

* Try:
Run with --info or --debug option to get more log output.

* Exception is:
org.gradle.api.GradleScriptException: A problem occurred evaluating root project 'spring-websocket-chat'.
        at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:92)
        at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl$2.run(DefaultScriptPluginFactory.java:187)
        at org.gradle.configuration.ProjectScriptTarget.addConfiguration(ProjectScriptTarget.java:77)
        at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:192)
        at org.gradle.configuration.BuildOperationScriptPlugin$1.run(BuildOperationScriptPlugin.java:61)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:317)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:309)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:185)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:95)
        at org.gradle.configuration.BuildOperationScriptPlugin.apply(BuildOperationScriptPlugin.java:58)
        at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:39)
        at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:26)
        at org.gradle.configuration.project.ConfigureActionsProjectEvaluator.evaluate(ConfigureActionsProjectEvaluator.java:34)
        at org.gradle.configuration.project.LifecycleProjectEvaluator.doConfigure(LifecycleProjectEvaluator.java:63)
        at org.gradle.configuration.project.LifecycleProjectEvaluator.access$100(LifecycleProjectEvaluator.java:33)
        at org.gradle.configuration.project.LifecycleProjectEvaluator$ConfigureProject.run(LifecycleProjectEvaluator.java:103)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:317)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:309)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:185)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:95)
        at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:49)
        at org.gradle.api.internal.project.DefaultProject.evaluate(DefaultProject.java:654)
        at org.gradle.api.internal.project.DefaultProject.evaluate(DefaultProject.java:132)
        at org.gradle.execution.TaskPathProjectEvaluator.configure(TaskPathProjectEvaluator.java:35)
        at org.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(TaskPathProjectEvaluator.java:60)
        at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:38)
        at org.gradle.initialization.DefaultGradleLauncher$ConfigureBuild.run(DefaultGradleLauncher.java:195)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:317)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:309)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:185)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:95)
        at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:157)
        at org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGradleLauncher.java:44)
        at org.gradle.initialization.DefaultGradleLauncher$1.run(DefaultGradleLauncher.java:122)
        at org.gradle.internal.work.DefaultWorkerLeaseService$2.execute(DefaultWorkerLeaseService.java:124)
        at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:116)
        at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:99)
        at org.gradle.launcher.exec.GradleBuildController.run(GradleBuildController.java:66)
        at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28)
        at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
        at org.gradle.tooling.internal.provider.ValidatingBuildActionRunner.run(ValidatingBuildActionRunner.java:32)
        at org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner$1.run(RunAsBuildOperationBuildActionRunner.java:43)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:317)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:309)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:185)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:95)
        at org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner.run(RunAsBuildOperationBuildActionRunner.java:40)
        at org.gradle.tooling.internal.provider.SubscribableBuildActionRunner.run(SubscribableBuildActionRunner.java:51)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:44)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28)
        at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:75)
        at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:49)
        at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:51)
        at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:32)
        at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:36)
        at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:25)
        at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:64)
        at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:29)
        at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:55)
        at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:42)
        at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:50)
        at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:30)
        at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:67)
        at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:37)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74)
        at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72)
        at org.gradle.util.Swapper.swap(Swapper.java:38)
        at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.exec.LogAndCheckHealth.execute(LogAndCheckHealth.java:55)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:62)
        at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:72)
        at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50)
        at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:297)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
        at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:46)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
Caused by: org.gradle.api.internal.plugins.PluginApplicationException: Failed to apply plugin [class 'io.spring.gradle.dependencymanagement.DependencyManagementPlugin']
        at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(DefaultPluginManager.java:150)
        at org.gradle.api.internal.plugins.DefaultPluginManager.addImperativePlugin(DefaultPluginManager.java:80)
        at org.gradle.api.internal.plugins.DefaultPluginManager.addImperativePlugin(DefaultPluginManager.java:86)
        at org.gradle.api.internal.plugins.DefaultPluginContainer.apply(DefaultPluginContainer.java:60)
        at org.springframework.boot.gradle.dependencymanagement.DependencyManagementPluginFeatures.apply(DependencyManagementPluginFeatures.java:44)
        at org.springframework.boot.gradle.SpringBootPlugin.apply(SpringBootPlugin.java:47)
        at org.springframework.boot.gradle.SpringBootPlugin.apply(SpringBootPlugin.java:38)
        at org.gradle.api.internal.plugins.ImperativeOnlyPluginTarget.applyImperative(ImperativeOnlyPluginTarget.java:41)
        at org.gradle.api.internal.plugins.RuleBasedPluginTarget.applyImperative(RuleBasedPluginTarget.java:49)
        at org.gradle.api.internal.plugins.DefaultPluginManager.addPlugin(DefaultPluginManager.java:165)
        at org.gradle.api.internal.plugins.DefaultPluginManager.access$200(DefaultPluginManager.java:47)
        at org.gradle.api.internal.plugins.DefaultPluginManager$AddPluginBuildOperation.run(DefaultPluginManager.java:252)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:317)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:309)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:185)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:95)
        at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(DefaultPluginManager.java:144)
        at org.gradle.api.internal.plugins.DefaultPluginManager.apply(DefaultPluginManager.java:125)
        at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.applyType(DefaultObjectConfigurationAction.java:113)
        at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.access$200(DefaultObjectConfigurationAction.java:36)
        at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction$3.run(DefaultObjectConfigurationAction.java:80)
        at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.execute(DefaultObjectConfigurationAction.java:136)
        at org.gradle.api.internal.project.AbstractPluginAware.apply(AbstractPluginAware.java:46)
        at org.gradle.api.internal.project.ProjectScript.apply(ProjectScript.java:34)
        at org.gradle.api.Script$apply$0.callCurrent(Unknown Source)
        at build_4b35wimvl540y84qjn2xnlyq9.run(/Users/Chaklader/IdeaProjects/spring-websocket-chat/build.gradle:4)
        at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:90)
        ... 88 more
Caused by: org.gradle.api.tasks.TaskInstantiationException: Could not create task of type 'DependencyManagementReportTask'.
        at org.gradle.api.internal.project.taskfactory.TaskFactory$1.call(TaskFactory.java:123)
        at org.gradle.api.internal.project.taskfactory.TaskFactory$1.call(TaskFactory.java:118)
        at org.gradle.util.GUtil.uncheckedCall(GUtil.java:402)
        at org.gradle.api.internal.AbstractTask.injectIntoNewInstance(AbstractTask.java:174)
        at org.gradle.api.internal.project.taskfactory.TaskFactory.create(TaskFactory.java:118)
        at org.gradle.api.internal.project.taskfactory.TaskFactory.create(TaskFactory.java:38)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory.create(AnnotationProcessingTaskFactory.java:51)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory.create(AnnotationProcessingTaskFactory.java:32)
        at org.gradle.api.internal.project.taskfactory.DependencyAutoWireTaskFactory.create(DependencyAutoWireTaskFactory.java:44)
        at org.gradle.api.internal.project.taskfactory.DependencyAutoWireTaskFactory.create(DependencyAutoWireTaskFactory.java:27)
        at org.gradle.api.internal.tasks.DefaultTaskContainer$TaskInstantiator.create(DefaultTaskContainer.java:301)
        at org.gradle.api.internal.tasks.DefaultTaskContainer$TaskInstantiator.create(DefaultTaskContainer.java:289)
        at org.gradle.api.internal.tasks.DefaultTaskContainer.create(DefaultTaskContainer.java:116)
        at org.gradle.api.internal.tasks.DefaultTaskContainer.create(DefaultTaskContainer.java:147)
        at org.gradle.api.internal.tasks.DefaultTaskContainer_Decorated.create(Unknown Source)
        at org.gradle.api.internal.tasks.DefaultTaskContainer_Decorated$create.call(Unknown Source)
        at io.spring.gradle.dependencymanagement.DependencyManagementPlugin.apply(DependencyManagementPlugin.groovy:57)
        at io.spring.gradle.dependencymanagement.DependencyManagementPlugin.apply(DependencyManagementPlugin.groovy)
        at org.gradle.api.internal.plugins.ImperativeOnlyPluginTarget.applyImperative(ImperativeOnlyPluginTarget.java:41)
        at org.gradle.api.internal.plugins.RuleBasedPluginTarget.applyImperative(RuleBasedPluginTarget.java:49)
        at org.gradle.api.internal.plugins.DefaultPluginManager.addPlugin(DefaultPluginManager.java:165)
        at org.gradle.api.internal.plugins.DefaultPluginManager.access$200(DefaultPluginManager.java:47)
        at org.gradle.api.internal.plugins.DefaultPluginManager$AddPluginBuildOperation.run(DefaultPluginManager.java:252)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:317)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:309)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:185)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:95)
        at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(DefaultPluginManager.java:144)
        ... 114 more
Caused by: org.gradle.internal.service.UnknownServiceException: No service of type StyledTextOutputFactory available in ProjectScopeServices.
        at org.gradle.internal.service.DefaultServiceRegistry.getServiceProvider(DefaultServiceRegistry.java:352)
        at org.gradle.internal.service.DefaultServiceRegistry.doGet(DefaultServiceRegistry.java:341)
        at org.gradle.internal.service.DefaultServiceRegistry.get(DefaultServiceRegistry.java:329)
        at org.gradle.api.internal.DependencyInjectingInstantiator.convertParameters(DependencyInjectingInstantiator.java:85)
        at org.gradle.api.internal.DependencyInjectingInstantiator.newInstance(DependencyInjectingInstantiator.java:54)
        at org.gradle.api.internal.ClassGeneratorBackedInstantiator.newInstance(ClassGeneratorBackedInstantiator.java:36)
        at org.gradle.api.internal.project.taskfactory.TaskFactory$1.call(TaskFactory.java:121)
        ... 141 more

BUILD FAILED in 0s

The gradle info is here,

When I try to synchronize the project, I get the message,

How can I just run the project properly ?

Body:
Try with this plugin.

plugins {
    id "io.spring.dependency-management" version "1.0.3.RELEASE"
}

documentation here


问:
Passing GET params to a Django View internally
I am trying to call a Django view internally from another view:

```<code>response = BlogViewSet.as_view({'get':'list'})(request)
</code>```

BlogViewSet is actually a rest framework view.
The above code works and I can access response.data but what I actually want to do is pass in some GET params to do some filtering. I tried the following but it didn't work:

```<code>response = BlogViewSet.as_view({'get':'list'})(request, my_param=something)
</code>```

I realise I could modify request to add GET params but it seems wrong to modify it as it might be used later in the view.

答:
You shouldn't ever call the view itself form another view.

You should instead try to extract the meaningful data / code out of the BlogViewSet view and call them directly from the various views.

Body:
I am trying to call a Django view internally from another view:

response = BlogViewSet.as_view({'get':'list'})(request)

BlogViewSet is actually a rest framework view.
The above code works and I can access response.data but what I actually want to do is pass in some GET params to do some filtering. I tried the following but it didn't work:

response = BlogViewSet.as_view({'get':'list'})(request, my_param=something)

I realise I could modify request to add GET params but it seems wrong to modify it as it might be used later in the view.


问:
jquery not working while submitting a form
```<code>$(document).ready(function(){
  $("#name").blur(function(){
    var name = $("#name").val();
      if ( $(this).val().match('^[a-zA-Z]{3,16}$') )
    {
    $("#check_name").html("Good Name").hide();
    }
else {
  $("#check_name").html("That's not a name.");
    }
</code>```

It is inserting the values if it is wrong.It is not validating data when we submit a form.need help soon.

答:
Try with regex pattern /pattern/g

```<code> $(this).val().match(/^[a-zA-Z]{3,16}$/g)
</code>```

Instead of

```<code>$(this).val().match('^[a-zA-Z]{3,16}$')
</code>```

It is not validating?

Because You are matching the string not with pattern

```<code>$(document).ready(function(){
  $("#name").blur(function(){
    var name = $("#name").val();
      if ( $(this).val().match(/^[a-zA-Z]{3,16}$/g) )
    {
    $("#check_name").html("Good Name").hide();
    }
else {
  $("#check_name").html("That's not a name.");
    }
</code>```

Body:
$(document).ready(function(){
  $("#name").blur(function(){
    var name = $("#name").val();
      if ( $(this).val().match('^[a-zA-Z]{3,16}$') )
    {
    $("#check_name").html("Good Name").hide();
    }
else {
  $("#check_name").html("That's not a name.");
    }

It is inserting the values if it is wrong.It is not validating data when we submit a form.need help soon.

Body:
Try with regex pattern /pattern/g

 $(this).val().match(/^[a-zA-Z]{3,16}$/g)

Instead of

$(this).val().match('^[a-zA-Z]{3,16}$')

It is not validating?

Because You are matching the string not with pattern

$(document).ready(function(){
  $("#name").blur(function(){
    var name = $("#name").val();
      if ( $(this).val().match(/^[a-zA-Z]{3,16}$/g) )
    {
    $("#check_name").html("Good Name").hide();
    }
else {
  $("#check_name").html("That's not a name.");
    }


问:
Incorrect syntax for SQL query
So I have this SQL Server query:

```<code>declare @symbol varchar(8) = '180460';
declare @sdate DATE = '20170630';
declare @edate DATE = '20170704';
IF @symbol = 'TSE00081'
    BEGIN
        SELECT * from dbo.IndexNames
    END
ELSE
BEGIN
    SELECT t1.qcode, t4.Name,t1.effectivedate, t1.publishdate, EventMap.Description, t1.SharesChanged, t1.FFW, t1.OldFFW,
    IIF(t1.EventCode='SK',t6.IndexName,''), IIF(t1.EventCode='SK',t7.Indexname,''), IIF(t1.Market<>'',t5.IndexName,''), IIF(t3.NameEn<>'',t3.NameEn,t2.NameEn),
    IIF(t1.OldSector<>'',t8.NameEn,''),  IIF(t1.Allotment1<>0 AND t1.EventCode<>'05', t1.Allotment2/t1.Allotment1,''), t1.SharesUnit
    FROM ( dbo.AdvNoticeData as t1 , dbo.IdTable as t4 )
    LEFT JOIN dbo.EventMap on t1.EventCode = dbo.EventMap.EventCode
    LEFT JOIN dbo.Industries as t2 on t1.SectorAsOf = t2.IndNum
    LEFT JOIN dbo.Industries as t3 on t1.Sector = t3.IndNum
    LEFT JOIN dbo.Industries as t8 on t1.OldSector = t8.IndNum
    LEFT JOIN dbo.IndexNames as t5 on t1.OldMarket = t5.Market
    LEFT JOIN dbo.IndexNames as t6 on t1.Scale = t6.Scale
    LEFT JOIN dbo.IndexNames as t7 on t1.OldScale = t7.Scale
    WHERE (t1.Market=1 or t1.MarketAsOf=1 or (t1.OldMarket=1 and t1.MarketAsOf=''))
    and t1.EffectiveDate >= @sdate and t1.EffectiveDate <= @edate and t1.Qcode = t4.Qcode
    ORDER BY t1.EffectiveDate, t1.EventCode, t1.Qcode
END
</code>```

the problem is after the FROM clause. I keep on getting incorrect syntax at ','

When I tried this command (with few modifications) on sqlyog, it works with that comma after the FROM clause. what seems to be the problem? here's the mysql counter part that works:

```<code>SELECT t1.qcode, t4.Name,t1.effectivedate, t1.publishdate,
EventMap.Description, t1.SharesChanged, t1.FFW, t1.OldFFW,
IF(t1.EventCode="SK",t6.IndexName,""),
IF(t1.EventCode="SK",t7.Indexname,""),
IF(t1.market<>"",t5.IndexName,""),
IF(t3.NameEn<>"",t3.NameEn,t2.NameEn),
IF(t1.oldSector<>"",t8.NameEn,""),
IF(t1.allotment1<>0 AND t1.eventcode<>"05",t1.allotment2/t1.allotment1,""),
t1.sharesunit
FROM (AdvNoticeData AS t1, IdTable AS t4)
LEFT JOIN EventMap ON t1.eventcode = EventMap.eventcode
LEFT JOIN Industries AS t2 ON t1.sectorasof = t2.IndNum
LEFT JOIN Industries AS t3 ON t1.sector = t3.IndNum
LEFT JOIN Industries AS t8 ON t1.oldsector = t8.IndNum
LEFT JOIN IndexNames AS t5 ON t1.oldmarket = t5.Market
LEFT JOIN IndexNames AS t6 ON t1.scale = t6.Scale
LEFT JOIN IndexNames AS t7 ON t1.oldscale = t7.Scale
WHERE (t1.market=1 OR t1.marketasof=1 OR (t1.oldmarket=1 AND t1.marketasof=""))
AND t1.effectivedate >= '20170630'
AND t1.effectivedate <= '20170703'
AND t1.Qcode = t4.Qcode
ORDER BY t1.effectivedate, t1.eventcode,t1.qcode
</code>```

答:
Modify your old JOIN syntax with an INNER JOIN

```<code>declare @symbol varchar(8) = '180460';
declare @sdate DATE = '20170630';
declare @edate DATE = '20170704';
IF @symbol = 'TSE00081'
    BEGIN
        SELECT * from dbo.IndexNames
    END
ELSE
BEGIN
    SELECT t1.qcode, t4.Name,t1.effectivedate, t1.publishdate, EventMap.Description, t1.SharesChanged, t1.FFW, t1.OldFFW,
    IIF(t1.EventCode='SK',t6.IndexName,''), IIF(t1.EventCode='SK',t7.Indexname,''), IIF(t1.Market<>'',t5.IndexName,''), IIF(t3.NameEn<>'',t3.NameEn,t2.NameEn),
    IIF(t1.OldSector<>'',t8.NameEn,''),  IIF(t1.Allotment1<>0 AND t1.EventCode<>'05', t1.Allotment2/t1.Allotment1,''), t1.SharesUnit
    FROM dbo.AdvNoticeData as t1
    INNER JOIN dbo.IdTable as t4 ON t1.Qcode = t4.Qcode
    LEFT JOIN dbo.EventMap on t1.EventCode = dbo.EventMap.EventCode
    LEFT JOIN dbo.Industries as t2 on t1.SectorAsOf = t2.IndNum
    LEFT JOIN dbo.Industries as t3 on t1.Sector = t3.IndNum
    LEFT JOIN dbo.Industries as t8 on t1.OldSector = t8.IndNum
    LEFT JOIN dbo.IndexNames as t5 on t1.OldMarket = t5.Market
    LEFT JOIN dbo.IndexNames as t6 on t1.Scale = t6.Scale
    LEFT JOIN dbo.IndexNames as t7 on t1.OldScale = t7.Scale
    WHERE (t1.Market=1 or t1.MarketAsOf=1 or (t1.OldMarket=1 and t1.MarketAsOf=''))
    and t1.EffectiveDate >= @sdate and t1.EffectiveDate <= @edate
    ORDER BY t1.EffectiveDate, t1.EventCode, t1.Qcode
END
</code>```

Title: Incorrect syntax for SQL query

Body:
So I have this SQL Server query:

declare @symbol varchar(8) = '180460';
declare @sdate DATE = '20170630';
declare @edate DATE = '20170704';
IF @symbol = 'TSE00081'
    BEGIN
        SELECT * from dbo.IndexNames
    END
ELSE
BEGIN
    SELECT t1.qcode, t4.Name,t1.effectivedate, t1.publishdate, EventMap.Description, t1.SharesChanged, t1.FFW, t1.OldFFW,
    IIF(t1.EventCode='SK',t6.IndexName,''), IIF(t1.EventCode='SK',t7.Indexname,''), IIF(t1.Market<>'',t5.IndexName,''), IIF(t3.NameEn<>'',t3.NameEn,t2.NameEn),
    IIF(t1.OldSector<>'',t8.NameEn,''),  IIF(t1.Allotment1<>0 AND t1.EventCode<>'05', t1.Allotment2/t1.Allotment1,''), t1.SharesUnit
    FROM ( dbo.AdvNoticeData as t1 , dbo.IdTable as t4 )
    LEFT JOIN dbo.EventMap on t1.EventCode = dbo.EventMap.EventCode
    LEFT JOIN dbo.Industries as t2 on t1.SectorAsOf = t2.IndNum
    LEFT JOIN dbo.Industries as t3 on t1.Sector = t3.IndNum
    LEFT JOIN dbo.Industries as t8 on t1.OldSector = t8.IndNum
    LEFT JOIN dbo.IndexNames as t5 on t1.OldMarket = t5.Market
    LEFT JOIN dbo.IndexNames as t6 on t1.Scale = t6.Scale
    LEFT JOIN dbo.IndexNames as t7 on t1.OldScale = t7.Scale
    WHERE (t1.Market=1 or t1.MarketAsOf=1 or (t1.OldMarket=1 and t1.MarketAsOf=''))
    and t1.EffectiveDate >= @sdate and t1.EffectiveDate <= @edate and t1.Qcode = t4.Qcode
    ORDER BY t1.EffectiveDate, t1.EventCode, t1.Qcode
END

the problem is after the FROM clause. I keep on getting incorrect syntax at ','

When I tried this command (with few modifications) on sqlyog, it works with that comma after the FROM clause. what seems to be the problem? here's the mysql counter part that works:

SELECT t1.qcode, t4.Name,t1.effectivedate, t1.publishdate,
EventMap.Description, t1.SharesChanged, t1.FFW, t1.OldFFW,
IF(t1.EventCode="SK",t6.IndexName,""),
IF(t1.EventCode="SK",t7.Indexname,""),
IF(t1.market<>"",t5.IndexName,""),
IF(t3.NameEn<>"",t3.NameEn,t2.NameEn),
IF(t1.oldSector<>"",t8.NameEn,""),
IF(t1.allotment1<>0 AND t1.eventcode<>"05",t1.allotment2/t1.allotment1,""),
t1.sharesunit
FROM (AdvNoticeData AS t1, IdTable AS t4)
LEFT JOIN EventMap ON t1.eventcode = EventMap.eventcode
LEFT JOIN Industries AS t2 ON t1.sectorasof = t2.IndNum
LEFT JOIN Industries AS t3 ON t1.sector = t3.IndNum
LEFT JOIN Industries AS t8 ON t1.oldsector = t8.IndNum
LEFT JOIN IndexNames AS t5 ON t1.oldmarket = t5.Market
LEFT JOIN IndexNames AS t6 ON t1.scale = t6.Scale
LEFT JOIN IndexNames AS t7 ON t1.oldscale = t7.Scale
WHERE (t1.market=1 OR t1.marketasof=1 OR (t1.oldmarket=1 AND t1.marketasof=""))
AND t1.effectivedate >= '20170630'
AND t1.effectivedate <= '20170703'
AND t1.Qcode = t4.Qcode
ORDER BY t1.effectivedate, t1.eventcode,t1.qcode

Body:
Modify your old JOIN syntax with an INNER JOIN

declare @symbol varchar(8) = '180460';
declare @sdate DATE = '20170630';
declare @edate DATE = '20170704';
IF @symbol = 'TSE00081'
    BEGIN
        SELECT * from dbo.IndexNames
    END
ELSE
BEGIN
    SELECT t1.qcode, t4.Name,t1.effectivedate, t1.publishdate, EventMap.Description, t1.SharesChanged, t1.FFW, t1.OldFFW,
    IIF(t1.EventCode='SK',t6.IndexName,''), IIF(t1.EventCode='SK',t7.Indexname,''), IIF(t1.Market<>'',t5.IndexName,''), IIF(t3.NameEn<>'',t3.NameEn,t2.NameEn),
    IIF(t1.OldSector<>'',t8.NameEn,''),  IIF(t1.Allotment1<>0 AND t1.EventCode<>'05', t1.Allotment2/t1.Allotment1,''), t1.SharesUnit
    FROM dbo.AdvNoticeData as t1
    INNER JOIN dbo.IdTable as t4 ON t1.Qcode = t4.Qcode
    LEFT JOIN dbo.EventMap on t1.EventCode = dbo.EventMap.EventCode
    LEFT JOIN dbo.Industries as t2 on t1.SectorAsOf = t2.IndNum
    LEFT JOIN dbo.Industries as t3 on t1.Sector = t3.IndNum
    LEFT JOIN dbo.Industries as t8 on t1.OldSector = t8.IndNum
    LEFT JOIN dbo.IndexNames as t5 on t1.OldMarket = t5.Market
    LEFT JOIN dbo.IndexNames as t6 on t1.Scale = t6.Scale
    LEFT JOIN dbo.IndexNames as t7 on t1.OldScale = t7.Scale
    WHERE (t1.Market=1 or t1.MarketAsOf=1 or (t1.OldMarket=1 and t1.MarketAsOf=''))
    and t1.EffectiveDate >= @sdate and t1.EffectiveDate <= @edate
    ORDER BY t1.EffectiveDate, t1.EventCode, t1.Qcode
END